Search code examples
clanguage-lawyernamingidentifierc11

Are user-defined identifiers beginning with a single underscore non-problematic?


Is this identifier non-problematic:

_var

C11, 7.1.3 Reserved identifiers, 1

All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.

Does it follow from this that user-defined identifiers beginning with a single underscore are non-problematic?


Solution

  • Yes. As long as:

    • are at block scope (includes enum/struct/union tags)
    • OR are struct/union members
    • OR are function parameters
    • _ is followed by neither capital nor another underscore

    E.g.

    struct X { int _a; };
    int main() { int _a; }
    void foo(int _a);