This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: newbe macro preprocessor question
- From: "John (Eljay) Love-Jensen" <eljay at adobe dot com>
- To: <andrea dot partinico at linsys dot it>, <gcc-help at gcc dot gnu dot org>
- Date: Mon, 4 Jun 2007 16:38:52 -0700
- Subject: RE: newbe macro preprocessor question
- References: <20070604230338.M99459@intra.linsys.it>
Hi Andrea,
>I'm not understanding why "mypoint" definition isn't expanded in myDISP invocation ?
It isn't expanded because the macro has already failed due to insufficient arguments. (The arguments are parsed first, and come up short.)
There are several techniques to do deferred macro expansion, which would then work as desired. The easiest would be to make
#define myDISP2(mypointer, mybyte_and_bit) myDISP(mypointer, mybyte_and_bit)
Alternatively, if you are using C++, you could (and in my opinion, should) use inline functions instead of macro functions.
HTH,
--Eljay