Search code examples
cmacrospreprocessor

What is the role of identifier in C preprocessor directives


When I execute the following code, the output is 5 6.

int main()
{
    int one = 5, two = 6;
    #ifdef next
    one = 2;
    two = 1;
    #endif
        printf("%d %d", one, two);
    return 0;
}

Definitely the code within #ifdef #endif is not getting excuted. I am unable to understand the utility of the identifier next. What is the keyword instead of next that will make the compiler execute the code inside the #ifdef #endif section?

reference


Solution

  • You simply define the macro

    #define next
    int main()
    {
        int one = 5, two = 6;
        #ifdef next
        one = 2;
        two = 1;
        #endif
            printf("%d %d", one, two);
        return 0;
    }
    

    Now the values will change.