Define w C.

0
#include <stdio.h>

int main()
{
    int a = 5;
    #define A a

    #if A == 5
        printf("sth\n");
    #endif

    return 0;
}

Dlaczego nie wyświetla 'sth'? przecież A to 5 ...

1

dlatemu

1
#include <stdio.h>
 
int main()
{
    int a = 5;
    #define A a
 
    if (A == 5)
        printf("sth\n");
 
    return 0;
}

Preparser działa przed właściwą kompilacją kodu, stąd wynik jest taki, a nie inny.

1 użytkowników online, w tym zalogowanych: 0, gości: 1