0

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.

Edited by Gonbe: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
0

>>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.

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.