Click to See Complete Forum and Search --> : Variables that start with _???
McBalls
12-05-2002, 09:25 PM
Hi,
What is the significance of variables (in C and C++) that start with _? For example _myVariabe??? I've seem it a lot, so it must be significant, and not just someone's idea of a good time.
Thanks,
mcballs
bwkaz
12-06-2002, 12:38 AM
I don't know if modern compilers still do it, but with ancent C compilers like Borland's Turbo C for DOS v2 (yeah, I know... :p), the underscore was prefixed by the compiler on all externally-available (i.e. non-static) symbols. It may be a holdover from that, or it might be something completely unrelated.
The only reason I know of it in that case is because Borland's assembler didn't do the prefixing, and it was in their list of known issues. So you had to do it yourself, which got annoying when you were trying to interface assembly and C...
Energon
12-06-2002, 02:24 AM
In C++ it's a somewhat common way of differentiating class members from local variables. I also believe that Microsoft uses them for their compiler specific variables and functions as well.
Think of it as a non-standard, but generally accepted way of using descriptive variable names without clashing with what programmers will be using. Most decent programmers just don't use the _ prepend because they know most compilers and APIs use them for that reason.