From: steve@robobar.co.uk (Steve Bleazard)
Newsgroups: biz.sco.general
Subject: Re: gcc 2.3.2 on SCO 3.2.4 (__STDC__)
Date: 23 Jan 93 14:53:17 GMT
Organization: Robobar Ltd., Perivale, Middx., ENGLAND.

In article <C1AC8D.JKq@wimsey.bc.ca> sl@wimsey.bc.ca (Stuart Lynne) writes:
>In article <DRG.93Jan22093904@candidus.ma30.bull.com> drg@candidus.ma30.bull.com (Daniel R. Guilderson) writes:
>>In article <9301212346.AA04169@jpradley.jpr.com> jpr@jpradley.jpr.com (Jean-Pierre Radley) writes:
>>
>>   > The solution is to get gcc 2.3.3 which eliminates the problem.
>>
>>   Oh? Really? Not here it didn't. I posted my patches the other day.
>>
>>All the patches I have seen come by here (maybe I missed yours) have
>>defined __STDC__ to be 0.  That is definitely wrong.  __STDC__ should
>>be defined as 1 for gcc.  Defining it as 1 causes problems in the SCO
>>header files but there is a script called fixincludes (or fixinc.sco)
>>which should fix the header files.
>
>Opinion varies. Some of use don't want our include files mucked up
>(some would say they are already mucked up enough). So we just
>set __STDC__=0. That does work well. I have very little problem
>getting things to compile under SCO with this.
>

The following attempts to rationalize the problems with the sco headers and
presents several alternate solutions that don't require the headers to be
munged:

SCO has made the headers ansi conformant.  Ansi says that if the ENVIRONMENT
is ansi the __STDC__ should be the constant 1.  ie everything must be ansi,
including the libraries.  If the environment is not ansi then __STDC__ may
either be another value or undefined (this comes from Plauger & Brodie's
Standard C).  Thus SCO have set __STDC__ to 0 when the ansi libraries aren't
being used (this is there -strict option).  This allows programs that
depend on ansi c syntax and library functions and use #ifdef __STDC__ to
work correctly while still allowing a stricter mode in which ansi library
usage is enforced.

Several solutions to the gcc / __STDC__ problem exist:

  1. Add -D__STDC__=0 to the %{!ansi...} section of CPP_SPEC 
     This will of course mean that you cannot use -ansi as this will
     cause strict conformance to be invoked.

  2. Change ansi in the various specs to pedantic and add -D__STDC__=0 to
     the %{!pedantic...} section of CPP_SPEC.  This will allow -ansi
     through to cc1 while using the standard libraries.

  3. Subdivide the %{ansi...} sections of the various specs into
     %{pedantic...} and %{!pedantic...}.  At the end of this message are
     replacement ..._SPEC macros to be used either in config/i386sco4.h or
     edited into gcc's specs file.  WARNING: I have NOT tested these mod's yet
     I've been working on the xenix version of gcc-2.3.3.

  4. Use solution 3 with -strict as the switch rather than -pedantic.

Steve

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	newspecs
# This archive created: Sat Jan 23 14:41:27 1993
export PATH; PATH=/bin:$PATH
if test -f 'newspecs'
then
	echo shar: will not over-write existing file "'newspecs'"
else
sed 's/^X//' << \SHAR_EOF > 'newspecs'
X#define STARTFILE_SPEC \
X "%{scoxpg3:%{p:mcrt1X.o%s}%{!p:crt1X.o%s}} \
X  %{!scoxpg3:\
X   %{posix:%{p:mcrt1P.o%s}%{!p:crt1P.o%s}} \
X   %{!posix:\
X    %{ansi:\
X     %{pedantic:%{p:mcrt1A.o%s}%{!p:crt1A.o%s}} \
X     %{!pedantic:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}} \
X    %{!ansi:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}}} \
X  crtbegin.o%s"
X
X#undef ENDFILE_SPEC
X#define ENDFILE_SPEC \
X "crtend.o%s \
X  %{scoxpg3:crtnX.o%s} \
X  %{!scoxpg3:\
X   %{posix:crtnP.o%s} \
X   %{!posix:\
X    %{ansi:\
X     %{pedantic:crtnA.o%s} \
X     %{!pedantic:crtn.o%s}} \
X    %{!ansi:crtn.o%s}}}"
X
X/* Library spec.  */
X
X#undef LIB_SPEC
X#define LIB_SPEC \
X "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} \
X %{scoxpg3:-lcX -lcP -lcA} \
X %{!scoxpg3:\
X  %{posix:-lcP -lcA} \
X  %{!posix:\
X   %{ansi:\
X    %{pedantic:-lcA} \
X    %{!padantic:%{scointl:-lintl} -lc}} \
X   %{!ansi:%{scointl:-lintl} -lc}}}"
X
X/* Macros, macros everywhere:
X   Specify predefined symbols in preprocessor.  */
X
X#undef CPP_PREDEFINES
X#define CPP_PREDEFINES "-Di386 -Dunix"
X
X#undef CPP_SPEC
X#define CPP_SPEC \
X "-D_M_I386 -D_M_I86 -D_M_I86SM -D_M_SDATA -D_M_STEXT \
X  -D_M_UNIX -D_M_XENIX \
X  -D_M_SYS5 -D_M_SYSV -D_M_SYS3 -D_M_SYSIII \
X  -D_M_COFF -D_M_BITFIELDS -D_M_WORDSWAP \
X  %{scoxpg3:-D_XOPEN_SOURCE -D_STRICT_NAMES} \
X  %{!scoxpg3:%{posix:-D_POSIX_SOURCE -D_STRICT_NAMES}} \
X  %{!scoxpg3:%{!posix:\
X   %{ansi:\
X    %{pedantic:-D_STRICT_NAMES}
X    %{!pedantic:-DM_I386 -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT \
X    -DM_UNIX -DM_XENIX \
X    -DM_SYS5 -DM_SYSV -DM_SYS3 -DM_SYSIII \
X    -DM_COFF -DM_BITFIELDS -DM_WORDSWAP -D__STDC__=0 \
X    %{scointl:-D_M_INTERNAT -DM_INTERNAT}}} \
X   %{!ansi:-DM_I386 -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT \
X    -DM_UNIX -DM_XENIX \
X    -DM_SYS5 -DM_SYSV -DM_SYS3 -DM_SYSIII \
X    -DM_COFF -DM_BITFIELDS -DM_WORDSWAP -D__STDC__=0 \
X    %{scointl:-D_M_INTERNAT -DM_INTERNAT} \
X    %{traditional:-D_KR -D_SVID -D_NO_PROTOTYPE}}}}"
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0
-- 
Steve.Bleazard@RoboBar.Co.Uk        | Phone:  +44 81 991 1142 x153
Snr Software Engineer, Robobar Ltd. | Fax:    +44 81 998 8343 (G3)
22 Wadsworth Road, Perivale.        |
Middx., UB6 7JD ENGLAND.            | ...!ibmpcug!robobar!steve
Newsgroups: biz.sco.general,comp.unix.sysv386,comp.lang.c