mercredi 4 avril 2018

Problems changing variable in #if

I have some problems in understanding how #if works. From this code:

int a, b;

#define VAR (a | b) 

void foo(int x)
{
    if(x)
        a = smth;
        b = smth2;
    else
        a = xmth;
        b = xmth2;
}   
int main()
{
    foo(x);
    #if(VAR != 0)
    {
        f = VAR;
    }
}

I can only change foo() but whatever the values for xmth/smth I get f=0. Why?

Thank you!

Aucun commentaire:

Enregistrer un commentaire