TITLE: variables and underscores PROBLEM: agerber@lookout.mtt.it.uswc.uswest.com (Andrew Gerber) Is there anything particularly bad or dangerous in prefixing all private data members with the _ (underscore) character? i.e.: private: int _value; ... the corporate Coding Standard mandates this type of usage. RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 1 Nov 95 Yes, it is dangerous to do that in code intended to be portable. Many identifiers that begin with an underscore are reserved to the system. The exact rules concerning which of these are reserved and in which contexts takes about a page in the C++ draft standard, and I'm not going to reproduce that here. The fact that it is so complicated to enumerate the exact patterns that are reserved and the contexts in which they are reserved is in my view sufficient reason to stay away from leading underscores entirely. (The rules are inherited from the C standard, with a few new wrinkles peculiar to C++. The C rules were an attempt to codify existing practice. I think the rules could have been made less complicated by futher restricting the user's name space, but those are the rules we have.) Apart from the identifiers reserved by the C++ standard, many system- dependent headers use identifiers with a leading underscore, including macros. Even when an identifier is supposed to be available for your use, you may find it has been co-opted, even if illegally, by the system. ("Yes, I see that gasoline truck, but he doesn't have the right of way so I'm not going to stop.") The risk of colliding with a system-defined name is so high that I have to recommend in the strongest terms against including this practice in a coding standard intended for application code. (In system-specific code where you control all naming conventions, you can do what you like.) A safe alternative is to use a trailing underscore: int value_;