通过#define和typedef的困惑 [英] Confused by #define and typedef
问题描述
#define T Stack_T
typedef struct T *T;
那么,什么是 T
在结构T
的意思是,通过定义的的#define
或的typedef
?
Then what does T
in struct T
mean,the one defined by #define
or typedef
?
推荐答案
的#define
指令在编译过程中(翻译阶段4月初上取代,编译不实际发生,直到第7阶段,这些阶段和他们有什么发生时在标准,部分5.1.1.2)详细说明。
#define
directives are substituted early on in the compilation process (translation phase 4, compilation doesn't actually occur until phase 7, these phases and what happens during them are detailed in the standard, section 5.1.1.2).
这是的#define
将简单的改变 T
pre-处理令牌, Stack_T
。
That #define
will simply change T
pre-processing tokens into Stack_T
.
那上的影响的typedef
将它变成:
typedef struct Stack_T *Stack_T;
在此之后, Stack_T
被定义为一个类型,指针的其他的类型结构Stack_T
。在 Stack_T
和结构Stack_T
是两个不同的东西。
Following that, Stack_T
is defined as a type, a pointer to another type of struct Stack_T
. The Stack_T
and struct Stack_T
are two separate things.
这篇关于通过#define和typedef的困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!