开发者

Viewing typedef replacement

Can anyone tell me, how can I see the typedef replacement string. Actually we could see the preprocessor replacement usin开发者_开发问答g cc -E filename.c . So like that I want to see the typedef replacement.


This (and also the -E) depends on the compiler you are using.

That said, I doubt this is possible with any compiler. Contrary to macros, typedefs are not just text replacements.

Please note also that the output of a potential typedef expanding program is not necessarily valid C code, e.g. instances the same struct will become incompatible.


typedefs are not macros.

-E is a preprocessor stage in compilation and you will be able to see only MACRO replacements.

#define A int *
typedef int *B;

Now this means wherever 'A' appears, it will be replaced by 'int *' - plain string replacement
However B is synonymous to saying 'int *'

So when I type :

A c, d;
B e, f;

The -E stage will show you that the following replacement has taken place :

int *c, d;
B e, f;

So :

c is of type 'int *'
d is of type 'int'
e is of type B (synonymous to saying e is of type 'int *')
f is of type B (synonymous to saying f is of type 'int *')

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜