Go Down

Topic: _ or __ in front of variables (Read 6158 times) previous topic - next topic



Newbie question here - but I have noticed on a few peoples example programs, the use of _ or __ in front of some variables. I was just wondering what the purpose of these underscores is?

Do they serve a purpose, or are they just so the variables stand out or something?



Typically, the underscore is used in front of member variables in a class, to distinguish them (for the reader) from local variables. The presence or absence of the _ (or __) makes no difference to the compiler.
The art of getting good answers lies in asking good questions.


So by 'member variables' you mean what I would call 'Global Variables' ?

As in variables that can be used throughout the sketch rather than local ones to a function.

Sorry coming from IEC PLC programming to this and still learning.

Since they have no effect to the compiler, that is good to know.



So by 'member variables' you mean what I would call 'Global Variables' ?

No, not at all, sorry.

What he means is variables that are part of a class.  
Not global, not local in a function, but in a separate class.

Go Up