C++,在多行代码中注释

标签 c++ gcc clang comments

代码不应该:

int Func(int a, // comment
         int b, // comment
         int c  // comment
        ) ...

相当于:

int Func(int a, // comment int b, // comment int c  // comment) ...

为什么它可以正确构建(至少使用 G++)?

到目前为止,我总是在这种情况下使用 /* */ 注释。

最佳答案

int Func(int a, // comment
         int b, // comment
         int c  // comment
        ) ...

转换为

int Func(int a,  
         int b,  
         int c   
        ) ...

third phase of translation 期间.如果你想在翻译阶段发生之前有一行等价的,那么你需要使用 /* */ like

    int Func(int a /*comment 1*/, int b /*comment 2*/, int c /*comment 3*/ ) ...

关于C++,在多行代码中注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51896653/

相关文章:

c++ - 线程特定指针如何工作

linux -/usr/include 中的头文件从哪里来? Linux 内核代码 或 Gcc

C++ 开始()和结束()

gcc - GCC/C语。如果某些-O标志在特定计算机上是最佳的,那么它们在另一台计算机上也是最佳的吗?

c++ - 为什么clang不编译在VS2012中可用的源代码?

c++ - 错误: 'high_resolution_clock' has not been declared

c++ - 在命名空间内转发声明全局类型

macos - 在 Mac 上从 llvm-g++-4.2 升级到 g++-4.7 的正确方法

c - 为什么使用返回值时0会被移入堆栈?

c++ - 在编译时填充 std::set?