Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 7
    They are common in libraries. They should not be common in user code. Commented Oct 23, 2008 at 7:12
  • 61
    People do write libraries in C, you know. Commented Oct 23, 2008 at 17:51
  • 12
    "Yes, underscores may be used anywhere in an identifier." This is wrong for global identifiers. See Roger's answer. Commented Jul 9, 2015 at 13:39
  • 2
    @sbi According to the C and C++ standards, yes, semantically, global identifiers with leading underscores are reserved. They are syntactically valid identifiers though, and the compiler won't stop you from naming a function _Foo, though by doing so you're relying on nonstandard implementation details and thus risk having your code broken by future versions of the language/standard library implementation/OS. Commented Jun 16, 2020 at 15:15
  • @BenW: TTBOMK, the C++ standard simply says that global identifiers starting with an underscore are not allowed, without making any distinction between syntax and semantic. (Also any identifiers starting with an underscore followed by a capital letter, and an identifiers with two consecutive underscores.) Commented Jul 11, 2020 at 21:14