Re: G_STMT_START / G_STMT_END on Sun
- From: Manish Singh <yosh gimp org>
- To: Tim Janik <timj imendio com>
- Cc: Gtk+ Developers <GTK-DEVEL-LIST GNOME ORG>, "ANDREW PAPROCKI, BLOOMBERG/ 731 LEXIN" <apaprocki bloomberg net>
- Subject: Re: G_STMT_START / G_STMT_END on Sun
- Date: Sat, 12 Nov 2005 12:15:25 -0800
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]