GCC: "__unused__" versus just "unused" in variable attributes

According to GCC's own documentation for variable attributes, the correct syntax for declaring an unused attribute is __attribute__((unused)) .

However, in many examples and other online code, I often see __attribute__((__unused__)) instead, and they both seem to work.

Is there any reason to either indicate or omit __ anyway? Does it matter, and is there a preferred version? Are there situations where using one and not the other can cause problems?

Presumably, the same applies to other attribute parameters?

+6
source share
1 answer

At the top of the page itself that you linked , it tells you:

You can also specify attributes with ' __ preceding and succeeding each keyword. This allows them to be used in header files without being bothered by a possible macro with the same name. For example, you can use __aligned__ instead of aligned .

Identifiers containing double underscores ( __ ) are reserved for implementation. Therefore, no user program can legally define them as macros.

+11
source

Source: https://habr.com/ru/post/978705/


All Articles