Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class members prefixed with underscore (_) [duplicate]

In our projects we decided to prefix member variables and some private/protected methods with underscore (so with “_”).

During a discussion it was claimed that this is discouraged to do because of some incompatibilities with some compilers/linkers on some platforms. As we want to be a portable as possible I'd like to be sure.

I also reckon that prefixing globals with underscores in C can be a problem.

Does the same apply to C++-linkage and if so, in which cases (platforms/compilers/linkers)?

like image 797
Patrick B. Avatar asked Nov 02 '11 11:11

Patrick B.


1 Answers

Personally, I use m_name, with 'm' standing for 'member'.

By the way, I also use p_ for parameters in my functions and g_ for the few unavoidable globals.

(then I usually get bashed by SO users because it looks like Hungarian notation ;-) But it is not.)

like image 149
Offirmo Avatar answered Oct 09 '22 14:10

Offirmo