Preprocessor #if directive

Posted by Caslav on Stack Overflow See other posts from Stack Overflow or by Caslav
Published on 2011-11-25T09:20:16Z Indexed on 2011/11/25 9:50 UTC
Read the original article Hit count: 160

Filed under:
|

I am writing a big code and I don't want it all to be in my main.c so I wrote a .inc file that has IF-ELSE statement with function and I was wondering can it be written like this:

#if var==1
process(int a)
{
    printf("Result is: %d",2*a);
}
#else
process(int a)
{
    printf("Result is: %d",10*a);
}
#endif

I tried to compile it but it gives me errors or in best case it just goes on the first function process without checking the var variable (it is set to 0).

© Stack Overflow or respective owner

Related posts about c

    Related posts about if-else