If one includes windows.h in a c++ file in Visual Studio, they then have a global identifier named STANDARD_RIGHTS_ALL defined. I would like to use that name as a name for a static member variable in a class I am creating. I attempted to do it as follows…
class ACLAmigo
{
public:
static int STANDARD_RIGHTS_ALL;
ACLAmigo(void);
~ACLAmigo(void);
};
Later on in another file I have this…
int ACLAmigo::STANDARD_RIGHTS_ALL = 1;
But the IDE complains thusly: “Error: expected an identifier”.
Question: Can I use this already declared identifier STANDARD_RIGHTS_ALL as a member variable name and if so how?
The problem is that
STANDARD_RIGHTS_ALL(and most of the other things) is the macro. Macros are always “globally defined”. Moreover, they’re resolved by the preprocessor before the compiler starts to analyze your code so that your code turns into:which is a nonsense.
Either pick another variable name, or undefine that macro: