How to define a define in C?

后端 未结 2 480
星月不相逢
星月不相逢 2021-01-17 10:16

Is it possible to write a #define that defines a #define?

For example:

#define FID_STRS(x) #x
#define FID_STRE(x) FID_STRS(         


        
2条回答
  •  情深已故
    2021-01-17 10:59

    No while defining macros u should take care of one thing that macro should not call itself (reccursively) either directly or indirectly.

    I know two static variables consuming 8 bytes will be expansive for u.

    I have solution over it

    #define FID_STRS2(x) #x
    #define FID_STRE(x) FID_STRS2(x)
    #define FID_DECL(n, v) static int FIDN_##n = v;static const char *FIDS_##n = FID_STRE(v)
    

    Just rename them going reccursive

提交回复
热议问题