注释 C/C++ 代码

注释 C/C++ 代码

问题描述:

最近我掌握了 Microsoft 的标准注释语言 (SAL) 用于注释 C/C++ 源代码.这个特性对于调试和开发过程非常有帮助,但不幸的是它不是一个可移植的跨平台库.是否有任何用于注释 C/C++ 代码的标准或开源工具?gcc 中是否有类似的功能?

Recently I got a grasp of Microsoft's Standard Annotation Language (SAL) for annotating C/C++ source codes. This feature can be very helpful for debugging and during development but unfortunately it is not a portable cross-platform library. Is there any standard or open-source tool for annotating C/C++ codes? Is there a similar feature available in gcc?

我所知道的最接近的是 GCC 的属性,但其他编译器不支持该语法.GCC 属性语法不支持与 SAL 一样多的注释,但您可能会发现其中一些注释很有用.

The closest that I'm aware is GCC's attributes, but other compilers don't support the syntax. GCC attribute syntax does not support as many annotations as SAL, but you may find some of the annotations useful.

或者,如果您使用模板,您可能需要查看 Boost Static断言,大多数编译器都支持.

Alternatively, if you're using templates, you may want to check out Boost Static Assert, which most compilers support.

还要注意CLANG支持的注解比GCC多,使用CLANG的静态分析器可能更接近你想要.

Also note that CLANG supports more annotations than GCC, and using CLANG's static analyzer may be closer to what you're wanting.