In the code I’m writing, I have been told to define a variable in a header file in the following way:
#define CLR_BLACK 0x0000
and since this is the only example I’ve been given, I was wondering whether all variables defined in a header file with the #define command need to be in caps. For example, would the following be valid?
#define videoBuffer (u16*)0x6000000
No. You can use any combination of alphanumeric characters and underscores. Don’t start with a number.
However a variable name like
videoBufferwould be difficult to distinguish from regular variables (without syntax coloring). That’s why most people either use all caps for preprocessor macros or start them with a lower casek, like this:kMyPreprocessorMacroEDIT: Those are not “global variables” by the way (as you tagged). They’re preprocessor macros. Basically an automatic find and replace mechanism that is run at compile time.