Home >Backend Development >C++ >What\'s the Purpose of Double Underscores in C Variable Names?

What\'s the Purpose of Double Underscores in C Variable Names?

DDD
DDDOriginal
2024-12-04 04:48:10932browse

What's the Purpose of Double Underscores in C   Variable Names?

The Usage of Double Underscores in C

When browsing through open-source C code, the frequent use of double underscores, particularly at the beginning of variable names, may be observed. Is this a common coding style or does it serve a specific purpose?

According to the "Programming in C , Rules and Recommendations" guide, the double underscore (__) in identifiers is strictly reserved for the compiler's internal use, as per ANSI-C standards. To avoid potential conflicts with these internal identifiers, it is advised against starting an identifier with an underscore.

Additionally, library functions often employ underscores in their names (e.g., "_main" and "_exit"). Therefore, to minimize clashes, it is recommended to refrain from commencing an identifier with an underscore.

The above is the detailed content of What\'s the Purpose of Double Underscores in C Variable Names?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn