Why Double Underscores Abound in C
In examining open-source C code, one may encounter a notable prevalence of double underscores "__" at the start of variable names. While this may seem perplexing or stylistically cumbersome, there is a specific rationale behind this practice.
As stated in the authoritative text "Programming in C , Rules and Recommendations," the convention of using two underscores in identifiers is exclusively reserved for the compiler's internal usage. This adheres to the ANSI-C standard, ensuring that user-defined code does not conflict with compiler-generated elements.
Furthermore, underscores are traditionally used to initiate the names of library functions, such as "_main" and "_exit." To prevent naming collisions, it is advisable to avoid commencing custom identifiers with an underscore.
Thus, the widespread usage of double underscores in C serves a practical purpose, enabling the compiler and library functions to operate seamlessly without interference from user-defined symbols.
The above is the detailed content of Why Do Double Underscores Appear Frequently in C Code?. For more information, please follow other related articles on the PHP Chinese website!