说“ #define FOO FOO”是什么意思?在C中? [英] What is the point of saying "#define FOO FOO" in C?
本文介绍了说“ #define FOO FOO”是什么意思?在C中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了一些 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
这样做的目的是什么? typedef不够吗?
What is the point of doing this? Shouldn't the typedef be enough? It is a workaround for some wonky C compilers out there?
推荐答案
使用 #define
指令,然后您就可以使用以下代码来测试typedef是否已在代码中的其他地方完成:
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;
#else
int myfoo;
#endif
这篇关于说“ #define FOO FOO”是什么意思?在C中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文