This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[RFC] Parametrized macro names
- From: Fabio Alemagna <falemagn at studenti dot unina dot it>
- To: <gcc at gcc dot gnu dot org>
- Date: Wed, 5 Mar 2003 03:00:00 +0100 (CET)
- Subject: [RFC] Parametrized macro names
I'm writing some code which would benefit greatly from the feature I'm
going to describe, and I suspect this feature could come handy to many
others as well, when playing with the preprocessor.
Basically, what I'd like the preprocessor to do is to allow this kind of
macro:
#define macro ## param1 ## param2 ## ... ## paramN macrobody
param1-N are macros themselves, and the above line defines a macro whose
name is composed of all the other macros' contents, making it parametrized
at all effects.
So, say I have the above #define in an include file, I could do this:
#define param1 ...
#define param2 ...
...
#define paramN ...
#include "macro.h"
And automatically get a new macro named after the parameter's contents.
Right now the preprocessor bails out on the parametrized definition,
because it says that '##' is not allowed at the beginning of a macro body,
so there's no possibility that the above line is ambiguous, and the
preprocessor could simply accept it and build the macro name accordingly.
I suspect it wouldn't be a too hard thing to implement either.
Regards,
Fabio Alemagna