Douglas Walls' Weblog

« Printing C language... | Main | Catching security... »
20060212 Sunday February 12, 2006

c89 command on linux

Suns's compilers have previewed on linux, take a look here http://developers.sun.com/prodtech/cc/linux_index.html.

This is just a preview, we have a long way to go before we can or will make this a product offering. On the way to doing that we got some feed back on the SDN, that our c89 command should work like the c89 command encountered on Linux.

Specifically, the following simple test case gets an error using the c89 command from Sun:

long long foo;

But the c89 command on linux accepts this declaration.

Why does the c89 (/bin/c89) command on linux allow this? It makes no sense at all, the entire purpose of the c89 command is to provide a portable compilation environment to those conforming to SUSv3. SUSv3 support the 1994 ISO C standard. long long is not an allowed type in the ISO 1994 C standard.

Sun is porting it's compiler from Solaris it Linux. On Solaris, Sun supports SUSv2 which defines the c89 command. We implement the c89 command by being pedantic about the 1994 C ISO language as required by SUSv2, and thus long long must not be accepted as a legal type. There are conformance tests that check this, and you cannot pass them without producing an error message.

We can change the error message into a warning and thus pass the conformance test and still present a consistent interface across Solaris and Linux.

But what we do not yet understand, is why /bin/c89 on linux does not produce even a warning message for the above program ...

( Feb 12 2006, 08:01:22 PM PST ) Permalink Comments [2]

Trackback URL: http://blogs.sun.com/dew/entry/c89_command_on_linux
Comments:

Use the source, Luke (aka UTSL). Find out how the "c89" command differs in implementation from the "gcc" command on Linux, and see if that gives you a hint about why it was imlpemented the way it was. -- That's what I would do if I had time, and cared. --chris

Posted by Chris Quenelle on February 12, 2006 at 09:14 PM PST #

<BODY >

Ah, I see the c89 script on RedHat has a bug...

From the GCC's "Projects you could work on":

"Add a configure option --enable-cc-links or similar which causes links
to the compiler driver or shell scripts to be installed under names cc
(the traditional Unix compiler name and a legacy utility in Unix98,
accepting an unspecified C language variant), c89 (POSIX; a script
running gcc -std=c89 -pedantic) and c99 (the Austin Group revision of
POSIX; a script running gcc -std=c99 -pedantic) for systems such as
GNU/Linux where GCC is the system compiler."


% more t.c
long long i;

% /usr/bin/c89 t.c -c
% /usr/bin/c89 t.c -c -pedantic
t.c:1: warning: ISO C90 does not support `long long'
opterra12% cat /usr/bin/c89
#!/bin/sh
fl="-std=c89"
for opt; do
case "$opt" in
-ansi|-std=c89|-std=iso9899:1990) fl="";;
-std=*) echo "`basename $0` called with non ANSI/ISO C option $opt" >&2
exit 1;;
esac
done
exec /usr/bin/gcc $fl ${1+"$@"}
%

</body>

Posted by Douglas Walls on February 13, 2006 at 05:00 PM PST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed

Search

Calendar

Links

Navigation

Referers