I have a device that can log into either one of two accounts.
The log-in credentials for both accounts are embedded in the code as #define statements.
When building the firmware for upload, I want to specify in one spot a condition that tell the compiler which set of #defines to compile and ignore the other set. The condition switch is the constant integer Account and it's set to 1.
The code below fails. It chooses the 2nd account when I want it to choose the first account.
why?
const int Account = 1; //set Account = 1 to build a firmware upload for Account 1
#if Account == 1
//use 1st account credentials
#undef AUTH
#define AUTH "xxxxxxxREDACTED1xxxxxxx"
#define Acct 1
#else // use 2nd account credentials
#undef AUTH
#define AUTH "xxxxxxREDACTED2xxxxxxx"
#define Acct 2
#endif
As @anon56112670 pointed out, this is wrong. It makes Account an integer variable, inaccessible by the pre-compiler. You must define Account as a pre-compiler macro symbol.