From: qralston@cislabs.pitt.EDU (James Ralston Crawford)
Subject: problems compiling X11R5 PL17 with gcc 2.2.2 [sun4, SunOS 4.1.2]
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 14 Sep 1992 11:08:02 GMT

	[I am not sure if my problem is the result of a bug with X11R5
PL17, or gcc 2.2.2, or both.  Please bear with me.]

	I am trying to compile X11R5 PL17 with gcc 2.2.2, on our sun4
running SunOS 4.1.2.  I successfully applied the README.X11 patch
contained in the distribution, even though the patch was intended for
PL12.

	In the `make World` step, I got some warnings, but nothing
serious.  However, in the `make install` step, here is what happened:

gcc -fpcc-struct-return -c -O2    -I../../.      gram.c
In file included from twm.h:297, from gram.c:44:
/long_gcc_path/include/stdlib.h:29: conflicting types for `malloc'
gram.c:1: previous declaration of `malloc'
/long_gcc_path/include/stdlib.h:33: conflicting types for `realloc'
gram.c:1: previous declaration of `realloc'

	Here is the section of twm.h that is causing the problems:

----- twm.h: lines 296-301
#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
#else
extern char *malloc(), *calloc(), *realloc(), *getenv();
extern void free();
#endif

	The stdlib.h that it is attempting to include is the version
that gcc's `make install-fixincludes` step "fixed" for me.

	From the mit/RELNOTES.TXT file:

----- mit/RELNOTES.TXT: lines 1137-1138
X_NOT_STDC_ENV means the system does not have ANSI C header files.   Thus,  for
example,  if  X_NOT_STDC_ENV  is not defined, it is safe to include <stdlib.h>.

	So stdlib.h will be included only if it is ANSI C.  The fixed
gcc version should be ANSI C.

	Here is Sun's default stdlib.h:

----- /usr/include/stdlib.h: lines 25,27,28,29,33
extern char *   calloc(/* size_t nmemb, size_t size */);
extern int      free(/* void *ptr */);
extern char *   getenv(/* const char *name */);
extern char *   malloc(/* size_t size */);
extern char *   realloc(/* void *ptr, size_t size */);

	Here is the "fixed" version:

----- /long_gcc_path/include/stdlib.h: lines 25,27,28,29,33
extern void *   calloc(/* size_t nmemb, size_t size */);
extern void     free(/* void *ptr */);
extern char *   getenv(/* const char *name */);
extern void *   malloc(/* size_t size */);
extern void *   realloc(/* void *ptr, size_t size */);

	So it boils down to one of two possibilities:

1.  The "fixed" stdlib.h that gcc's `make install-fixincludes` made is
    supposed to be ANSI C, but is not.  Therefore, when it is
    included, it conflicts with definitions that already exist.
    Conclusion: the install-fixincludes step for gcc 2.2.2 is broken.

2.  The "fixed" stdlib.h that gcc's `make install-fixincludes` made
    *is* ANSI C.  Somewhere in the building process for X11, though,
    things get defined in non-ANSI ways, but X_NOT_STDC_ENV does *not*
    get defined.  Therefore, the gcc ANSI C stdlib.h is included,
    which conflicts with the existing non-ANSI definitions.
    Conclusion: something with PL17 is broken and defining things in
    non-ANSI ways.

	I suspect #2, because I managed to successfully install PL12
using this exact same procedure, yet PL17 breaks.

	My question is:

1.  Is the "fixed" stdlib.h segment above truly ANSI C, or is it not?

	[I'm sorry if that's a "is the sky blue" question, but I
haven't had time to pick up C yet.  The answer is not obvious to me;
neither are pointers to the answer.]

	Thanks, and regards,

James

-- 
James Ralston Crawford \ Advanced Technology Lab                   The
qralston@cislabs.pitt.edu \ qralston@pittvms.bitnet                 Phantom
"Pitiful creature of darkness \ What kind of life have you known"  - of the
"God gave me courage to show you \ You are not alone"                 Opera