【问题标题】:The difference between __attribute__((unused)) and __attribute((unused)) in GCCGCC 中 __attribute__((unused)) 和 __attribute((unused)) 的区别
【发布时间】:2018-09-26 09:56:18
【问题描述】:

__attribute__((unused))__attribute((unused)) 可以将变量标记为未使用以避免未使用警告。

它们有什么区别?

【问题讨论】:

  • @unwind 你能回答这个问题吗?非常感谢。
  • 可以吗?只记录了第一个语法!
  • @JanHudec 是的,可以。
  • @JanHudec 你的意思是 __attribute((unused)) 不存在?
  • 您可以找到manual 来澄清这些事情。是的,区别在于__attribute 只是正确的__attribute__ 的拼写错误。

标签: c++ c gcc gcc-warning


【解决方案1】:

在 GCC 存储库中,在文件 c-common.c 中,定义了类型为 struct c_common_resword 的数组 c_common_reswords

在数组中,你会发现以下元素:

 { "__attribute",   RID_ATTRIBUTE,  0 },
 { "__attribute__", RID_ATTRIBUTE,  0 },

并且RID_ATTRIBUTEenum rid 部分的c-common.h 中定义/* C extensions */

所以__attribute__attribute__ 是一样的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-11
    • 1970-01-01
    • 2015-04-01
    • 1970-01-01
    • 2020-03-17
    • 2019-07-06
    • 2021-06-17
    • 1970-01-01
    相关资源
    最近更新 更多