🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by James Ralston Crawford Mon, 14 Sep 1992 11:08
problems compiling X11R5 PL17 with gcc 2.2.2 [sun4, SunOS 4.1.2]
#1140
Author: James Ralston Crawford
Date: Mon, 14 Sep 1992 11:08
93 lines
4094 bytes
	[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
Re: problems compiling X11R5 PL17 with gcc 2.2.2 [sun4, SunOS 4.1.2]
#1149
Author: Rainer Klute
Date: Tue, 15 Sep 1992 10:28
45 lines
2137 bytes
In article <9209141908.AA03141@phantom.cislabs.pitt.edu>,
qralston@cislabs.pitt.EDU (James Ralston Crawford) writes:
|> 
|> 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'


The problem stems from the broken SunOS yacc which prepends the generated
code with non-ANSI definitions for malloc() and realloc(). The following
patch to twm's Imakefile "fixes" the problem by brute force:


*** /tmp/RCSAa24446     Tue Sep 15 12:23:32 1992
--- mit/clients/twm/Imakefile   Thu Aug 13 18:18:07 1992
***************
*** 32,41 ****
--- 32,48 ----
  ComplexProgramTarget(twm)
  InstallNonExecFile(system.twmrc,$(TWMDIR))
  
+ #if HasGcc2 && defined (SunArchitecture)
  gram.h gram.c: gram.y
        yacc $(YFLAGS) gram.y
+       sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c
+       $(MV) y.tab.h gram.h
+ #else
+ gram.h gram.c: gram.y
+       yacc $(YFLAGS) gram.y
        $(MV) y.tab.c gram.c
        $(MV) y.tab.h gram.h
+ #endif
  
  clean::
        $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c 


-- 
  Dipl.-Inform. Rainer Klute      klute@irb.informatik.uni-dortmund.de
  Univ. Dortmund, IRB
  Postfach 500500         |)|/    Tel.: +49 231 755-4663
D-W4600 Dortmund 50       |\|\    Fax : +49 231 755-2386
Re: problems compiling X11R5 PL17 with gcc 2.2.2 [sun4, SunOS 4.1.2]
#1153
Author: Carson A. Gaspar
Date: Tue, 15 Sep 1992 20:15
15 lines
867 bytes
I noticed the same thing.  The problem, however, was in the generated
gram.c. If I used bison to generate it from gram.y, it compiled with
no problems.

from gram.c:

extern char *malloc(), *realloc();

# line 42 "gram.y"
#include <stdio.h>
..

-- 
			    Carson Gaspar
			carson@cs.columbia.edu
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads