Re: [gtk-list] Re: compiling gtk+ on solaris



On Thu, 23 Dec 1999 14:09:31 +0100, Drazen Kacar wrote:
> Erik Mouw wrote:
>> Which is the same on a SuSE Linux 6.1 and a Debian 2.1 box. Does this mean
>> that SGI and XFree86 add ANSI compliant prototypes to each function, or
>> that Sun *removes* the prototypes?
> 
> I think Sun didn't touch them. I suppose other vendors added the missing
> declarations, which is what one would expect for OS's where gcc is the
> only compiler, at least. I didn't check the original X distribution, so I
> might be wrong.

I just downloaded Xlib.h from the X11R6.3 distribution and it *doesn't*
contain proper prototypes.

> XDoesBackingStore() is declared as extern int on Solaris, too. It's not that
> all such functions don't have return value declared. Only some of
> them. Maybe they should really be void and not int. OTOH, there are
> some which are explicitely declared as such. It's weird.
> 
> Here are some not explicitely declared:
> 
> extern XActivateScreenSaver(
> #if NeedFunctionPrototypes
>     Display*            /* display */
> #endif
> );
> 
> extern XAddHost(
> #if NeedFunctionPrototypes
>     Display*            /* display */,
>     XHostAddress*       /* host */
> #endif
> );

This is *exactly* as they are declared in the X11R6.3 source. SGI IRIX 6.3
and Linux declare them as:

  extern int XActivateScreenSaver(
  #if NeedFunctionPrototypes
      Display*            /* display */
  #endif
  );

  extern int XAddHost(
  #if NeedFunctionPrototypes
      Display*            /* display */,
      XHostAddress*       /* host */
  #endif
  );

> Man pages also doesn't have more information about the type returned. I think
> these should be void, but I'm not 100% sure.

I think XFree86 and SGI looked at the source to find out the proper return
type.

>> > Although it's annoying when gcc compiles C program, it's not a real
>> > problem. But g++ (new versions) will refuse to compile those files.
>> 
>> And for valid reasons. The gcc team worked towards a *correct* C/C++
>> compiler implementation. Sometimes this means that previously assumed
>> correct C constructions fail with gcc 2.95.2, but my experience is that
>> all "sane coded" programs pass gcc 2.95.2 with no or little changes.
> 
> Sun's C compiler doesn't warn in this case. I haven't tried with their
> C++ compiler, though.

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.

>> I can't decide which is worse: Sun changing the include files or X/Open
>> *not* adding proper prototypes.
> 
> Tough decision, I agree. :-)

Which is worse: X/Open not adding proper prototypes, or Sun not
implementing a proper C compiler? :-)


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]