【问题标题】:Should we use _In_ instead of __in?我们应该使用 _In_ 而不是 __in 吗?
【发布时间】:2011-05-04 19:56:18
【问题描述】:

我今天阅读了 VS2010 中的 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     |         |        |          |          |               |
|            |            |         |        |          |          |               |
|------------|------------|---------|--------|----------|----------|---------------|

我一直使用这些注释。
我不敢相信它们已被弃用。是真的吗?
如果有,为什么?
从现在开始我们应该使用以下注释吗? -我不熟悉:(

|--------------|----------|----------------|-----------------------------|
|   Usage      | Nullness | ZeroTerminated |  Extent                     |
|--------------|----------|----------------|-----------------------------|
| _In_         | <>       | <>             | <>                          |
| _Out_        | opt_     | z_             | [byte]cap_[c_|x_]( size )   |
| _Inout_      |          |                | [byte]count_[c_|x_]( size ) |
| _Deref_out_  |          |                | ptrdiff_cap_( ptr )         |
|--------------|          |                | ptrdiff_count_( ptr )       |
| _Ret_        |          |                |                             |
| _Deref_ret_  |          |                |                             |
|--------------|          |                |                             |
| _Pre_        |          |                |                             |
| _Post_       |          |                |                             |
| _Deref_pre_  |          |                |                             |
| _Deref_post_ |          |                |                             |
|--------------|----------|----------------|-----------------------------|

顺便说一下,SO 中不存在 SAL 标签。
如果可以的话,请努力。

【问题讨论】:

  • 嗯?这看起来像 SQL ......你指的是什么语言? Windows、Visual Studio 和 Microsoft 不是语言。我猜是 MS SQL,但.h 表示 C 或 C++。
  • SAL 不是一种语言。它是 c/c++ 的注解。
  • Mark:SAL 是源代码注释语言 (msdn.microsoft.com/en-us/library/ms235402(VS.100).aspx),用于注释 C/C++ 函数中的参数,以便编译器和其他工具可以给出更好的警告。

标签: windows visual-studio-2010 visual-c++ annotations


【解决方案1】:

看来你应该习惯新的“属性”SAL格式了,看这篇文章中间的红色评论:

Link

【讨论】:

    猜你喜欢
    • 2011-06-10
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 2011-03-02
    • 2010-09-28
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    相关资源
    最近更新 更多