cwick cwick - 1 year ago 66
C Question

What is the point of saying "#define FOO FOO" in C?

I came across some C code where the author uses the following idiom all over the place:

typedef __int32 FOO_INT32;
#define FOO_INT32 FOO_INT32

What is the point of doing this? Shouldn't the typedef be enough? It is a workaround for some wonky C compilers out there?

Answer Source

With the #define instruction, you'll then be able to test if the typedef has been done somewhere else in the code using :

#ifdef FOO_INT32
FOO_INT32 myfoo;
int myfoo;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download