Hello Daniweb,

I've ran against an issue in my code and i'm not sure why I receive an error. I've managed to reproduce the error with the following code:

#ifdef _WIN32
#define PERFORMANCE_METING
#endif

#ifdef PERFORMANCE_METING
#include <windows.h>
#endif

#include <stdio.h>
#include <stdlib.h>

typedef enum { FALSE, TRUE } Boolean;

int main()
{
    return 0;
}

This code gives me the following error for the line where the typedef is:

error: syntax error before numeric constant

Could anyone tell me why what I did is not allowed?
Besides that I was wondering if it was possible to check 2 symbols in 1 line with ifdef. (e.g. ifdef _WIN32 && PERFORMANCE_METING or something) or can I only use #if defined(_WIN32) && defined(PERFORMANCE_METING) for that?

Thanks in advance,

Gonbe.

-edit-
It doesn't seem to like include <windows.h> for some reason.
Do not know why though.

-edit-
Windef.h has a definition for FALSE and TRUE.. guess that's the issue.

>>This code gives me the following error for the line where the typedef is:

windows.h already defines TRUE and FALSE, which are #define's, not typedefs. I suppose you could undefine them before that typedef, but that could cause many other problems with win32 api functions.

>>or can I only use #if defined(_WIN32) && defined(PERFORMANCE_METING) for that?

Yes. But then you could have tried it yourself to find out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.