通过#define和typedef的困惑 [英] Confused by #define and typedef

查看:104
本文介绍了通过#define和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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆