[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

cpp oddness



The output of "cpp test.c" on the attached file:

# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
test.c:5:2: warning: #warning TEST_FIVE defined
test.c:8:2: warning: #warning TEST_NINE defined
# 15 "test.c"
test.c:25:2: warning: #warning 4 and 7 claim to be equal
enum __stuff { TEST_FOUR = 4, TEST_SEVEN = 7 };
# 28 "test.c"
test.c:33:2: warning: #warning TEST_THREE defined
test.c:36:2: warning: #warning TEST_EIGHT defined
test.c:40:2: warning: #warning 3 and 8 claim to be equal
enum __stuffandnonsense { TEST_THREE = 3, TEST_EIGHT = 8 };

Is this correct or buggy behavior?  If correct, how can I test whether
or not the RLIMIT_ enumerations in <sys/resource.h> are equal to one
another?
#define TEST_FIVE 5
#define TEST_NINE 9

#ifdef TEST_FIVE
#warning TEST_FIVE defined
#endif
#ifdef TEST_NINE
#warning TEST_NINE defined
#endif

#if (TEST_FIVE == TEST_NINE)
#warning 5 and 9 claim to be equal
#endif

enum __stuff { TEST_FOUR = 4, TEST_SEVEN = 7 };

#ifdef TEST_FOUR
#warning TEST_FOUR defined
#endif
#ifdef TEST_SEVEN
#warning TEST_SEVEN defined
#endif

#if (TEST_FOUR == TEST_SEVEN)
#warning 4 and 7 claim to be equal
#endif

enum __stuffandnonsense { TEST_THREE = 3, TEST_EIGHT = 8 };
#define TEST_THREE TEST_THREE
#define TEST_EIGHT TEST_EIGHT

#ifdef TEST_THREE
#warning TEST_THREE defined
#endif
#ifdef TEST_EIGHT
#warning TEST_EIGHT defined
#endif

#if (TEST_THREE == TEST_EIGHT)
#warning 3 and 8 claim to be equal
#endif



Reply to: