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

7

今天我阅读了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++。 - mpen
2
SAL不是一种编程语言,而是C/C++的注释。 - Benjamin
5
Mark:SAL(Source-code Annotation Language)是一种用于注释C/C++函数参数的语言(http://msdn.microsoft.com/en-us/library/ms235402(VS.100).aspx),以便编译器和其他工具能够提供更好的警告。请注意,翻译后的内容保留原意并使之更加易懂,不得添加解释或其他额外内容。 - Gabe
1个回答

7

看起来你应该开始适应新的“属性”SAL格式,参见此文章中间的红色注释:

链接


另一个链接,提供完整的解释和示例:一个declspec SAL转Attribute SAL石头 - Michiel van Oosterhout

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接