`Cpp: 'ICOM_FN(##xfn)' generates a warning :-(

Francois Gouget fgouget@free.fr
Wed Jan 3 10:01:00 GMT 2001


On 3 Jan 2001, Alexandre Oliva wrote:

> On Jan  2, 2001, Francois Gouget <fgouget@free.fr> wrote:
> 
> > #define DECLARE2(xfn)    void ICOM_FN(##xfn) (void);
> 
> This doesn't produce a valid token after token pasting.  CVS GCC is
> correct in warning about it.
> 
> I think an ISO C-compliant solution would be to define DECLARE2 so
> that it takes an additional empty argument, and use token pasting to
> paste this empty argument to the symbol name.
> 
> #define DECLARE2(xfn,empty) void ICOM_FN(empty ## xfn) (void);
> 
> DECLARE2(GetObject,)

   Brilliant!
   I didn't think about that, I like it.


> The alternative I see to preserve the interface of DECLARE2 is to not
> use ICOM_FN, but instead concatenate fn with xfn explicitly.

   The problem with this solution is that, I should have said so, we
change the definition of ICOM_FN depending on another macro. So ICOM_FN
does not always prepend fn. So we would have to duplicate all the macros
that use ICOM_FN. Feasible but ugly.


   But I like your first suggestion. I'll implement it, that way we'll
avoid all problems.

   Thanks.


--
Francois Gouget         fgouget@free.fr        http://fgouget.free.fr/
  Good judgment comes from experience, and experience comes from bad judgment
                               -- Barry LePatner



More information about the Gcc mailing list