develooper Front page | perl.perl5.porters | Postings from September 2006

[PATCH] cflags.SH: The Revenge of gcc-std=c89

Thread Next
From:
Jarkko Hietaniemi
Date:
September 30, 2006 02:58
Subject:
[PATCH] cflags.SH: The Revenge of gcc-std=c89
Message ID:
451E3FD0.3020700@iki.fi
The attached patch for cflags.SH would do the following
(only when using gcc):

- scan separately for -ansi, -pedantic (yes, they can
  be used separately), and -std=c89
- and the various gcc -Woptions

The scan is done using a test source code file that attempts
to include the usual suspects of system headers.  Only the options
that give no errors and produce an executable are accepted.

Tested in Solaris (gcc 3.3) (where as expected -ansi and -pedantic are
not accepted as valid options), Ubuntu (gcc 4.0.3) x86, Tru64 (gcc 3.3),
and Mac OS X (gcc 4.0.0) ppc.

But before applying this more testing is definitely wanted and needed,
especially in HP-UX (where H.Merijn reported a lot of hassle last time
I tried to introduce the -std=c89), AIX (traditionally a tricky
platform), and Rafael remembered running into some not-so-clean
Linux headers.  IRIX?  Cygwin?

Maybe this more rabid option checking should be enabled only under
-Dusedevel?  Or maybe some new Configure flag, -Dgccstrict?
(See also Note 2 below)

I have to confess that I'm not fully convinced that this patch
does more good than evil (because of the problems -std=c89 caused
earlier, and see e.g. Note 3 below), and some systems simply may have
too weird system headers to render this patch unworkable.  Therefore
I won't cry overly much if this patch doesn't get applied.  Well, maybe
sniffle a bit.

Note 1: as before, the cflags(.SH) is used only for the compilation
of the core source code files, not for extensions.

Note 2: I am uncertain of what to make of the Configure variable
$gccansipedantic now that the usability of -ansi and -pedantic is
tested in cflags.SH.  This needs more thought.

Note 3: In gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061)
the -std=c89 seems to whine (for every file) about our (optional) use of
C99 macros:

perl.h:1500:38: warning: anonymous variadic macros were introduced in C99
perl.h:1512:39: warning: anonymous variadic macros were introduced in C99

but in gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5) that whinage seems
not to appear.  This may or may not be a problem, and may or may not
be indicative of some larger problem.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About