Re: [gtk-list] Re: compiling gtk+ on solaris
- From: Erik Mouw <J A K Mouw its tudelft nl>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: compiling gtk+ on solaris
- Date: Thu, 23 Dec 1999 21:43:08 +0100 (MET)
On Thu, 23 Dec 1999 15:43:07 +0100, Drazen Kacar wrote:
> Erik Mouw wrote:
>> On Thu, 23 Dec 1999 14:09:31 +0100, Drazen Kacar wrote:
>> I think XFree86 and SGI looked at the source to find out the proper return
>> type.
>
> Could be. OTOH, K&R C says that undeclared functions return int, so it's
> safe to put it even without looking at the source.
True, although I can only find it as a short remark in the book (section
4.1 of K&R (ANSI edition) after the grep example).
>> Gcc and SGI's C compiler both warn in this case (and for good reasons), so
>> that's the reason why XFree86 and SGI changed the include files. So it
>> turns out to be a "bug" in the Sun C compiler.
Correction: SGI's C compiler doesn't issue a warning for omitting the
return type. Sorry, my fault.
> I'd agree if there wasn't something strange going on. Sun's cc has -Xc
> option which:
>
> c (conformance)
> Strictly conformant ANSI/ISO C, without K&R C compati-
> bility extensions. The compiler will issue errors and
> warnings for programs that use non-ANSI/ISO C con-
> structs.
>From my SunOS 4.1.3 days, I can't remember that the -Xc option was
especially useful... Luckily we had gcc with -Wall. Maybe it changed with
Solaris.
> I tried to compile Xlib program on which I'm currently working with cc -Xc,
> but it didn't complain. Then I tried with lint. It complained about
> undeclared exit() (I forgot to #include <stdlib.h>), but not about
> X include files. Then I tried with Sun's CC. It printed an error
> about undeclared exit() and refused to compile, but nothing about X stuff.
> They all have their private include directories, but there are no X include
> files there. I cannot explain this.
g++ 2.95.2 is actually quite confident about functions without type,
consider this "program":
main(void) { return 0; }
g++ -o nonansi nonansi.c
nonansi.c:1: warning: ANSI C++ forbids declaration `main' with no type
Given the effort the gcc team put in the proper implementation of the C++
standard, I'm quite sure that C++ indeed requires a return type. But then
again: I can't check it without a copy of the C++ standard.
>> Which is worse: X/Open not adding proper prototypes, or Sun not
>> implementing a proper C compiler? :-)
>
> Sun not adding proper prototypes. I'll have to find out why CC and lint
> don't complain before concluding they didn't implement proper compilers
> and filing a bug report.
I think that omitting the return type is valid in C, but invalid in C++.
Therefore, lint is correct, and Sun CC is not.
"The first thing we do, let's kill all the language lawyers." -- William
Shakespeare, Henry IV, part II
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]