美文网首页
微软源代码注释语言(SAL)

微软源代码注释语言(SAL)

作者: 玻璃缸里的自游 | 来源:发表于2019-03-11 19:35 被阅读0次

    The Microsoft source-code annotation language (SAL) provides a set of annotations that you can use to describe how a function uses its parameters, the assumptions that it makes about them, and the guarantees that it makes when it finishes. The annotations are defined in the header file <sal.h>. Visual Studio code analysis for C++ uses SAL annotations to modify its analysis of functions.

    Natively, C and C++ provide only limited ways for developers to consistently express intent and invariance. By using SAL annotations, you can describe your functions in greater detail so that developers who are consuming them can better understand how to use them.

    Simply stated, SAL is an inexpensive way to let the compiler check your code for you.
    SAL can help you make your code design more understandable, both for humans and for code analysis tools.

    void * memcpy(
       _Out_writes_bytes_all_(count) void *dest, 
       _In_reads_bytes_(count) const void *src, 
       size_t count
    );
    

    微软MSDN参考

    相关文章

      网友评论

          本文标题:微软源代码注释语言(SAL)

          本文链接:https://www.haomeiwen.com/subject/bscipqtx.html