Re: ## issue with glib.h



Darin Adler <darin@eazel.com> writes:

> on 8/9/00 1:57 PM, Raja R Harinath at harinath@cs.umn.edu wrote:
> 
> > One instance that I fixed it was in ORBit/src/IIOP/iiop-encoders.h
> 
> I fixed that same problem on the stable branch (you only did HEAD) and a
> similar problem elsewhere in ORBit.
> 
> > Deprecated GCC way (used in glib.h):
> > #define g_message(format, args...) g_log(DOM, LOG_LEV, format, ##args)
> > 
> > ISO C 1999 way:
> > #define g_message(format_args...) g_log(DOM, LOG_LEV, format_args)
> > 
> > The problem the '##' solves in the first (deprecated) style is when
> > args is empty -- in which case it swallows the preceding ',', IOW
> > it allows g_message("abc") rather than forcing g_message("abc",).
.
> > The second style is supported in GCC too (well, I checked GCC
> > 2.7.2.3, and it worked).  So, we should probably just move to that,
> > and maybe relax the #ifdef to include ISO C99.
> 
> Great news! We should definitely move to the new syntax to avoid the warning
> with the new picker version of GCC.

Hmmm, but the second is _NOT_ C99 vararg syntax. It's simply using
the GCC syntax in way that avoids using ##.

The C99 way would be:

 #define g_message(...) g_log (DOM, LOG_LEV, __VA_ARGS__)

Which certainly won't work with 2.7.2.3. 

I think the conclusion on the GCC list was that this particular
warning should not have been introduced, and it will be removed
again. But we should be migrating away from using the GCC 
extension, since the plan is not to support the extension moving
forward.

The best way of fixing it is probably to check for __VA_ARGS__
in configure, and if found, use that even for GCC. Moving
to Raja's variant above will remove the warning, but does
not get rid of the use of a GCC extension.

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]