This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Preprocessor question...


Is the following valid code?

#include <stdio.h>
#define OFFSET (0x1000)
#define NUMBER (0x0E+OFFSET)
int main()
{
    printf("%d\n", NUMBER);
    return 0;
}

I get the following error when compiling with egcs-1.1.2 or gcc-2.95.2:

test.c: In function `main':
test.c:8: missing white space after number `0x0E'
test.c:8: `OFFSET' undeclared (first use in this function)
test.c:8: (Each undeclared identifier is reported only once
test.c:8: for each function it appears in.)

The code works if I put spaces around the "+":
e.g. #define NUMBER (0x0E + OFFSET)

My guess is the preprocessor thinks "0x0E+" is a floating point constant?
Anyway, the code also works if I use a different hex digit:
e.g. #define NUMBER (0x0A+OFFSET)

Not really a big deal, I'm just curious...
Anyone have an explanation?

Thanks,
 - Glen Nakamura


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]