This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: including <stdlib.h>
- To: jfc at mit dot edu, robertl at dgii dot com
- Subject: Re: including <stdlib.h>
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Wed, 11 Feb 1998 12:22:27 -0500 (EST)
- Cc: egcs at cygnus dot com
> From: Robert Lipe <robertl@dgii.com>
>
> > Another approach would be to supply a "system.h" file which
> > includes various headers (eg stdlib.h), provides possibly missing system
> > prototypes (eg bcopy) and possibly missing system macros (eg R_OK),
> > etc., and each gcc source file could then include this file if desired
> > to get default stuff. (Or the source file could instead enumerate these
> > things manually if the default system.h is not appropriate.)
>
> This would ease maintenance costs, but would presumably cost us
> something during the compilation phase becuase then everything that
> includes systems.h also picks up a presumably non-small amount of header
> stuff that it now gets to preprocess. I don't know what that cost
> actually is in measureable terms, and we might decide it's worth it.
> I just wanted to throw it out for discussion.
>
Yes depending on the cost, that point could be valid. Perhaps
we only want to include the most frequently used system headers? I
did a survey using the following shell command (get ready for a
mouthful):
grep '^#.*include.*<' {.,cp,objc,f,config/*}/*.[ch] | sed 's/.*</</' | \
awk '{print$1}' | sort | uniq -c | sort -nr
I've appended the results at the end of this message. I think its
clear that we probably want "system.h" to include <stdio.h> and not
bother with <float.h>. :-) But exactly where the cutoff should be I
don't know. Maybe we can start with what I submitted and see if it
actually affects compilation time in a noticeable way. It turns out
that the files in my draft system.h are typically the more frequently
included by the gcc source.
> Personally, if the cost is anything less than horrible, I'm inclined
> to support a migration to it.
Agreed, centralizing this stuff is a win from a maintenance
point of view. Programmer time is at a higher premium than cpu time.
> > Hmmm, I just checked the list archive and for some reason the
> > file I submitted seems to have stripped all the include statements so
> > they appear without the file its trying to include inside <>. Wierd...
>
> I've noticed that on the web archives. I assumed it was the
> html-ification process not correctly replacing those characters with <
> and > so as to escape them from tags.
Ah, that makes sense. Thanks.
--Kaveh
198 <stdio.h>
64 <stdlib.h>
56 <ctype.h>
47 <string.h>
30 <sys/types.h>
26 <errno.h>
22 <unistd.h>
18 <stdarg.h>
17 <varargs.h>
16 <time.h>
16 <strings.h>
15 <sys/stat.h>
14 <signal.h>
13 <stddef.h>
13 <setjmp.h>
13 <limits.h>
10 <sys/time.h>
10 <objc/thr.h>
10 <malloc.h>
10 <fcntl.h>
10 <alloca.h>
9 <sys/param.h>
7 <sys/file.h>
6 <locale.h>
5 <sys/resource.h>
5 <stab.h>
5 <pthread.h>
5 <netbsd.h>
5 <m68k/m68k.h>
5 <i386/gstabs.h>
4 <xm-netbsd.h>
4 <xm-lynx.h>
4 <xm-linux.h>
4 <windows.h>
4 <sys/mman.h>
4 <sparc/sparc.h>
4 <process.h>
4 <lynx.h>
4 <linux-aout.h>
4 <inttypes.h>
4 <i386/xm-i386.h>
4 <dirent.h>
4 <config.h>
4 <a.out.h>
3 <lynx-ng.h>
3 <gnu-versions.h>
2 <thread.h>
2 <sys/wait.h>
2 <sys/times.h>
2 <sys/dir.h>
2 <sparc/xm-sparc.h>
2 <sparc/sysv4.h>
2 <objc/objc.h>
2 <mon.h>
2 <math.h>
2 <m68k/xm-m68k.h>
2 <m68k/coff.h>
2 <linux.h>
2 <libintl.h>
2 <io.h>
2 <i386/perform.h>
2 <gnu.h>
2 <descrip.h>
2 <arm/xm-arm.h>
2 <ansidecl.h>
1 <xm-gnu.h>
1 <xm-freebsd.h>
1 <unixlib.h>
1 <ulocks.h>
1 <syscall.h>
1 <sys/vmparam.h>
1 <sys/vmmac.h>
1 <sys/varargs.h>
1 <sys/sysmp.h>
1 <sys/signal.h>
1 <sys/prctl.h>
1 <sys/m88kbcs.h>
1 <synch.h>
1 <syms.h>
1 <syidef.h>
1 <svr4.h>
1 <string.h>
1 <stdio.h>
1 <stamp.h>
1 <ssdef.h>
1 <sgs.h>
1 <rs6000/rs6000.h>
1 <pcthread.h>
1 <os2.h>
1 <objc/typedstream.h>
1 <ns32k/xm-ns32k.h>
1 <ns32k/ns32k.h>
1 <nam.h>
1 <mips/mips.h>
1 <machine/sysnews.h>
1 <machine/machparam.h>
1 <mach_o_vals.h>
1 <mach_o_types.h>
1 <mach_o_header.h>
1 <mach_o_format.h>
1 <mach/mach.h>
1 <mach/cthreads.h>
1 <link.h>
1 <ldfcn.h>
1 <i386/linux.h>
1 <i386/i386.h>
1 <i386/gas.h>
1 <i386/att.h>
1 <float.h>
1 <fab.h>
1 <dirent.h>
1 <demangle.h>
1 <dbxstclass.h>
1 <assert.h>
1 <ar.h>
1 <aoutos.h>
1 <alloc.h>
--
Kaveh R. Ghazi Project Manager / Custom Development
ghazi@caip.rutgers.edu ICon CMT Corp.