samedi 11 avril 2020

C error with using else macro "expected parameter declarator"

I wrote the following C code (according to the C99 standard) and it ran with no problems:

#include <stdio.h>

#ifdef _WIN32
printf("Running on Windows");
#endif

void test(int x);

int main() {
    return 0;
}

but adding else caused so much errors (around 12) what's the problem with the new code:

#ifdef _WIN32
printf("Running on Windows");
#else
printf("Running on Windows");
#endif

Some of the errors:

error: expected parameter declarator
expected ')'
warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
error: conflicting types for 'printf'

Aucun commentaire:

Enregistrer un commentaire