Fwd: Re: G_STMT_START / G_STMT_END on Sun



Yosh, it appears that the #define for sun is not really necessary anymore unless
 GLib is still supported on older SunOS platforms. All of the newer Sun
compilers support the "do {} while(0)" syntax, so it can either be removed or an
 explicit check for SunOS4 can be put in. I was going to propose a patch after I
 try to track down the explicit compiler version that had a prob. -Andrew

----- Original Message -----
From: Manish Singh  <yosh gimp org>
At: 11/12 15:15

On Sat, Nov 12, 2005 at 02:28:21PM +0100, Tim Janik wrote:
> On Fri, 11 Nov 2005, ANDREW PAPROCKI, BLOOMBERG/ 731 LEXIN wrote:
>
> >Can anyone tell me what Sun compiler required that G_STMT_START/G_STMT_END
> >be
> >written as follows:
> >
> ><inside gmacros.h>
> >#    if (defined (sun) || defined (__sun__))
> >#      define G_STMT_START      if (1)
> >#      define G_STMT_END        else (void)0
> >#    else
> >
> >This is causing me headaches now and no longer seems to be any kind of
> >requirement when compiling with even semi-recent Sun compilers:
> >
> >$ cat a.c
> >#include <stdio.h>
> >int main(void)
> >{
> >   do { printf("foo\n"); } while(0);
> >}
> >$ /opt/SUNWspro61/bin/cc -o a a.c
> >$ /opt/SUNWspro8/bin/cc -o a a.c
> >$
> >
> >Also, the macros are written in such a way that if you are using GCC in
> >strict
> >ANSI mode on a Sun machine, you will get the silly "if (1) else (void) 0"
> >macros
> >instead of the normal "do while(0)".
> >
> >The end result of all of this is that the following code generates
> >warnings on
> >recent GCC versions on Solaris:
> >
> >if (1)
> >   g_assert_not_reached();
> >
> >$ /opt/gcc-3.4.3/bin/gcc <options here> -ansi test.c
> >warning: suggest explicit braces to avoid ambiguous `else'
> >
> >If someone knows why those Sun checks existed in the first place, I'll
> >post a
> >patch to fix these macros to prevent this issue on Sun machines. The
> >comment
> >indicates they came from Perl code, but does not mention any version
> >numbers.
> >Next step, dig out the Perl src to see if they have an idea :)
>
> the first mentioning of that is in a 1997 email from owen, i have
> appended it. so if you're looking for a particular perl version, it's
> one from before that date ;)

Current perl still has it, except they've now tacked && !defined(__GNUC__)
on the end. So glib could read:

#    if (defined (sun) || defined (__sun__)) && && !defined(__GNUC__)

Would this change address things for you? Or are you seeing breakage on
non-gcc Sun compilers as well?

-Yosh






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