What is the reason for underscore in C variable name definition?

Maybe this helps, from C99, 7.1.3 (“Reserved Identifiers”):

  • All identifiers that begin with an underscore and either an uppercase letter or another
    underscore are always reserved for any use.

  • 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.

Moral: For ordinary user code, it’s probably best not to start identifiers with an underscore.

(On a related note, I think you should also stay clear from naming types with a trailing _t, which is reserved for standard types.)

Leave a Comment