conf 斜杠注释不起作用,如何在//注释中转义反斜杠

"这篇博客讨论了在C++中遇到的多行注释警告问题,当注释以反斜杠()结尾时,Clang编译器会发出警告。作者提到尝试在反斜杠后添加空格但未解决问题。解决方案是确保在反斜杠后面放置其他字符以避免行延续。文章提供了几个示例来说明如何正确处理这种情况。"
摘要由CSDN通过智能技术生成

I have a comment that ends with backslash. Something like

...

// use \

..

Clang(++) warned me, that this is multi-line comment

warning: multi-line // comment [-Wcomment]

// use \

^

So I try add some whitespace at the end, but didn't help. Can I escape backslash somehow?

解决方案

The foundation of the issue is the definition of a line continuation.

When a line ends with a backslash-newline combination or combination, the compiler appends the next line of text to the present line of text. This can be demonstrated with macros:

#define ME {\

cout << "me\n" \

}

The above will be treated as the single line:

#define ME {cout << "me\n"}

The compiler is complaining because your "//" comment extends to the next line because the '\' continuation character.

Solution:

Put other characters after the '\'.

Examples:

'\'

\ ending character

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值