C++,用多行代码注释

Pie*_*tro 1 c++ gcc comments clang

不应该代码:

int Func(int a, // comment
         int b, // comment
         int c  // comment
        ) ...
Run Code Online (Sandbox Code Playgroud)

相当于:

int Func(int a, // comment int b, // comment int c  // comment) ...
Run Code Online (Sandbox Code Playgroud)

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

到目前为止,我总是/* */在这种情况下使用评论.

Nat*_*ica 6

int Func(int a, // comment
         int b, // comment
         int c  // comment
        ) ...
Run Code Online (Sandbox Code Playgroud)

转换为

int Func(int a,  
         int b,  
         int c   
        ) ...
Run Code Online (Sandbox Code Playgroud)

翻译第三阶段.如果你想在翻译阶段之前使用单行等效,那么你需要使用/* */like

    int Func(int a /*comment 1*/, int b /*comment 2*/, int c /*comment 3*/ ) ...
Run Code Online (Sandbox Code Playgroud)