I have a C program that has platform-specific definitions for accessing low-level hardware. On some platforms, two macros point to the same variable, while on others they are different:
//Platform_One.h #define FOO_PORT (io.portA) #define BAR_PORT (io.portB) //Platform_Two.h #define FOO_PORT (io.portC) #define BAR_PORT (io.portC) //same
I have an initializer code that is different from whether #defines are the same or not. Conceptually, I would like the code to look like this:
callback_struct_t callbacks[] = { #if FOO_PORT == BAR_PORT //unfortunately invalid {&FOO_PORT, handle_foo_bar_func}, #else {&FOO_PORT, handle_foo_func}, {&BAR_PORT, handle_bar_func}, #endif {0,0} };
Is there a reliable way to test at compile time if two arbitrary macros have the same definition?
c c-preprocessor
Ashelly
source share