saving a #define before an #undef

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • myheartinamerica

    #1

    saving a #define before an #undef

    Hello,

    I was working on a piece of code where a vendor's #define was causing
    compiler warnings, which led me to try and do the following:

    #if defined(VAR1)
    #define VAR1_SAVE VAR1
    #undef VAR1
    #endif
    #define VAR1 1
    #define VAR2 (10 - VAR1)
    #undef VAR1
    #if defined(VAR1_SA VE)
    #define VAR1 VAR1_SAVE
    #undef VAR1_SAVE
    #endif

    Even if this is ridiculous, I'm unsure as to why it didn't work. Any
    insights? I needed VAR2 to be #defined in terms of VAR1, but I needed
    it to be my own locally #define'd VAR1.
Working...