Reputation: 3
I'm trying to run the following code with and without the '-D DEBUG' gcc flag:
#include <stdio.h>
#ifdef DEBUG
printf("Defined");
#else
printf("Not defined");
#endif
int main()
{
}
The error I get is "debugtest.c:6:9: error: expected declaration specifiers or ‘...’ before string constant"
Upvotes: 0
Views: 505
Reputation: 224844
Your call to printf
has to be inside a function:
#include <stdio.h>
int main()
{
#ifdef DEBUG
printf("Defined");
#else
printf("Not defined");
#endif
return 0;
}
Upvotes: 3