Confusingly #define and typedef

#define T Stack_T
typedef struct T *T;

Then what does meaning Tin struct T, meaning, specific #defineor typedef?

+2
source share
4 answers
Directives

#define are replaced at an early stage of the compilation process (translation phase 4, compilation does not actually occur until phase 7, these phases and what happens during them are described in detail in the standard, section 5.1.1.2).

That #definewill simply change the preprocessing tokens Tto Stack_T.

The effect of this on typedefwill be to turn it into:

typedef struct Stack_T *Stack_T;

After that it is Stack_Tdefined as a type, a pointer to another type struct Stack_T. Stack_Tand struct Stack_T- two separate things.

+8

,

typedef struct Stack_T *Stack_T;

, T Stack_T, , typedef struct Stack_T*.

, struct Type Type ++, C.

+3

#define struct , typedef struct T *T; : typedef struct Stack_T *Stack_T;

0

T Stack_T, typedef :

typdef struct Stack_T *Stack_T;

T Stack_T .

0

All Articles