This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


On Wed, 3 Jan 2001, Francois Gouget wrote:

> 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.

   Oups. I talked too fast. It's still brilliant and I didn't think of
it. But I got confused and thought I could just modify ICOM_FN when in
fact it's DECLARE I have to modify, i.e. in Wine ICOM_METHOD. These
macros are used to declare each COM method (about 1500 of them so far).
Of course, I'd rather not add commas all other the place.

   Is there any other way I could avoid the prescan?


> > 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.

   Well, less of a problem than modifying the 1500 uses of the
ICOM_METHOD macros. It means instead I'l duplicate the definition of
(only) 33 macros :-(


   Currently it looks like so:


#ifndef ICOM_CINTERFACE

#define ICOM_METHOD(ret,xfn) \
     public: virtual ret CALLBACK (xfn)(void) = 0;
#define ICOM_METHOD1(ret,xfn,ta,na) \
     public: virtual ret CALLBACK (xfn)(ta a) = 0;
...

#define ICOM_FN(xfn)             xfn

#else /* ICOM_CINTERFACE */

#ifdef __WINE__
#define ICOM_FN(xfn)             fn##xfn
#else
#define ICOM_FN(xfn)             xfn
#endif

#define ICOM_METHOD(ret,xfn) \
    ret CALLBACK (*ICOM_FN(##xfn))(ICOM_INTERFACE* me);
#define ICOM_METHOD1(ret,xfn,ta,na) \
    ret CALLBACK (*ICOM_FN(##xfn))(ICOM_INTERFACE* me,ta a);
...

#endif /* ICOM_CINTERFACE `*/

#define ICOM_CALL(xfn, p)        ICOM_VTBL(p)->ICOM_FN(##xfn)(p)
...


--
Francois Gouget         fgouget@free.fr        http://fgouget.free.fr/
 "Only wimps use tape backup: _real_ men just upload their important stuff on
       ftp, and let the rest of the world mirror it ;)" -- Linus Torvalds



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]