相关疑难解决方法(0)

"_in_"和"_in_opt_"在C++/CLI中意味着什么?

我是CLR的新手,我正在阅读setWindowPos的c ++/CLI文档,并且函数定义如此.

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
);
Run Code Online (Sandbox Code Playgroud)

我有c ++的经验,所以我理解,例如,"HWND"是数据类型,"hWnd"是变量名.

但是什么是" _ in _"和"_in_opt_"?

我猜它们是"输入变量"或其他东西的缩写.

文档中提到hWndInsertAfter是可选的.这是否意味着我可以简单地省略/不打扰在我的函数调用中将变量传递给此参数,如果我不需要?

例如

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

(这会让我感到困惑,因为我已经看到它在其他地方写的C++不支持可选参数.只有默认参数和重载)

c++-cli

10
推荐指数
1
解决办法
7441
查看次数

我们应该使用_In_而不是__in吗?

我今天读到了VS.h中的sal.h.
我有点惊讶.

// This section contains the deprecated annotations
|------------|------------|---------|--------|----------|----------|---------------|
|   Level    |   Usage    |  Size   | Output | NullTerm | Optional |  Parameters   |
|------------|------------|---------|--------|----------|----------|---------------|
| <>         | <>         | <>      | <>     | _z       | <>       | <>            |
| _deref     | _in        | _ecount | _full  | _nz      | _opt     | (size)        |
| _deref_opt | _out       | _bcount | _part  |          |          | (size,length) |
|            | _inout     |         |        |          |          |               |
|            | …
Run Code Online (Sandbox Code Playgroud)

windows annotations visual-studio-2010 visual-c++

7
推荐指数
1
解决办法
3570
查看次数