12

I'm fairly new to CLR, I'm reading the c++/CLI documentation for setWindowPos and the function is defined like so.

BOOL WINAPI SetWindowPos(
  _In_      HWND hWnd,
  _In_opt_  HWND hWndInsertAfter,
  _In_      int X,
  _In_      int Y,
  _In_      int cx,
  _In_      int cy,
  _In_      UINT uFlags
);

I have experience in c++ so I understand that, for example, "HWND" is the data type and "hWnd" is the variable name.

But what are "_in_" and "_in_opt_"?

I'm guessing they're short for "input variables" or something.

It is mentioned in the documentation that the hWndInsertAfter is optional. Does this mean I can simply omit/not bother passing a variable to to this parameter in my function call if I don't need to?

e.g.

SetWindowPos(this,0,0,GetSystemMetrics(SM_CXMAXIMIZED),GetSystemMetrics(SM_CYMAXIMIZED),SWP_NOZORDER);
//Note that we're one parameter short here (the second is missing)

(This would be confusing to me, as I've seen it written in other places that C++ does not support optional parameters. Only default parameters and overloading)

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Guy Joel McLean
  • 1,019
  • 4
  • 12
  • 34
  • 2
    possible duplicate of [What is \_In\_ in C++?](http://stackoverflow.com/questions/11457328/what-is-in-in-c) – Sparr May 28 '13 at 17:52
  • Yes, i just located this similar topic. I'll admit that my initial research was not good enough, sorry. However, the answer I got from this question was a touch more relevant to my specific questions. – Guy Joel McLean May 28 '13 at 17:59

1 Answers1

20

This is part of Microsoft's Source-Code Annotation Language. _In_Opt_ means you may pass NULL.

mwerschy
  • 1,698
  • 1
  • 15
  • 26
  • 1
    Thank you very much. Now that I have a name for these annotations (I originally thought that they were interpreted and meant something significant to the compiler), I have a starting point for further research. – Guy Joel McLean May 28 '13 at 18:03
  • _In_opt_ (opt is all lower case!) – txs Apr 23 '19 at 22:13