Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?
From: Gregor Copoix (logical_at_xeption.de)
Date: 06/28/04
- Next message: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Previous message: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- In reply to: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Next in thread: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Reply: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Reply: Phlip: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 28 Jun 2004 13:39:12 -0700
> > I have a set of macros that create variable names depending of the
content
> > of some other define.
> > An example (of how it should look like in the end):
> > // --------------- cut
> > #define BASE_NAME module1
> > // the macro(s) which I need help for :-)
> > #define MAKE_VARNAME2(base, var,val) int var#_#base = val
> > #define MAKE_VARNAME(var, val) MAKE_VARNAME2(BASE_NAME, var, val)
> > // the usage example
> > MAKE_VARNAME(status, 0);
> > // --------------- cut
> >
> > which should expand to
> > int status_module1 = 0;
> You need to use the token merging operator (##) rather than
stringification
> operator (#), like this:
> #define MAKE_VARNAME2(base, var,val) int var##_##base = val
But this results still in an lvalue error as the concaternated text is a
string for the preprocessor.
int "var_module1" = 0;
and results in an compiler error.
I tried both # and ##.
Gregor
- Next message: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Previous message: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- In reply to: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Next in thread: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Reply: Måns Rullgård: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Reply: Phlip: "Re: Q: C macro's for lvalue statements ? Any C marco Guru's out there ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|