[CentOS] about C program of CPP macro problems
Michael Hennebry
hennebry at web.cs.ndsu.nodak.edu
Tue Dec 10 15:45:23 UTC 2013
On Tue, 10 Dec 2013, Nicol TAO wrote:
> I want to using #define / #undef, and want to put them in a single macro,
> some thing like:
>
> #define DECALRE_TYPE(type) \
> { #undef __curr_type; #define _curr_type type; }
>
> as we know, this can not passed with CPP, but I need this logical here.
I think that you are out of luck.
The preprocessor will not macro-expand one line into more than one line.
Also, #s generated from macro-expansion do not count as preprocessor flags.
To get two lines from one, you need #include.
#include "dcltype"
Have one such file per type.
> Generally, the problem comes from
>
> #define ser_field(type, var) \
> ser_new_field(tra, #type, #var, offsetof(struct_type, var))
>
> I do not want another additional parameter in this macro like
>
> #define ser_field(type,var,struct_type), and I want a sentence declare
> "current struct type"
> and all later work of ser_field will defaultly use this type.
--
Michael hennebry at web.cs.ndsu.NoDak.edu
"SCSI is NOT magic. There are *fundamental technical
reasons* why it is necessary to sacrifice a young
goat to your SCSI chain now and then." -- John Woods
More information about the CentOS
mailing list