This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Testing validity of macro arguments
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: "James Lamanna" <jamesl at appliedminds dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Thu, 17 Jul 2003 15:56:27 -0500
- Subject: Re: Testing validity of macro arguments
Hi James,
Assuming that your macro is called "MagicFn" (with $dostuff$ doing the appropriate thing)...
#define MagicFn(MacroParm) $dostuff$
...where you use the macro you can do this at invocation:
#ifndef MyParm
#error MyParm must be a macro
#endif
MagicFn(MyParm)
If, instead, you want to do something like this...
#define MagicFn(MacroParm) \
#ifndef MacroParm \
#error MacroParm must be a macro \
#endif \
$dostuff$
... you can't do it in C/C++ with the C/C++ preprocessor.
The only way to do that is to run a PRE-preprocessor of your own devising. You could write one that would be sufficient in Flex & Bison, or Perl, or sed.
HTH,
--Eljay