且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[[maybe_unused]]关于成员变量,GCC警告(错误?)该属性被忽略

更新时间:2023-11-11 15:03:58

任何原因都可以出于任何原因被编译器忽略",除非标准另有规定(例如,在明确指出的位置使用属性)禁止).

Any attribute can be "ignored by the compiler" for any reason, except where the standard says otherwise (such as using an attribute in a location where it is expressly forbidden).

GCC并不是说你不能在那放一个;这就是说,将一个放在那儿什么也做不了,因为它们可能不会警告可能未使用的成员变量.

GCC isn't saying you can't put one there; it's saying that putting one there won't do anything, because they probably don't warn about maybe-unused member variables.