🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3698

-I vs relative includes

#3698
From: Andy Wick
Date: Tue, 06 Jul 1993 22:33
46 lines
2269 bytes
What are the pros and cons of -I's vs relative includes?

Our system currently does more then 10,000 includes when a full
baseline build to done.  All gcc command lines contain at least 14 
"-I"'s so that we don't need relative paths in our files.  Approx 60% of
our include lines are system includes.  I assume this means that inorder to
find the system include file, 15+ stat()s must be done, since /usr/include is
searched last (and this must stay this way, no -I- suggestions :) Since we
are currently revamping our code, and we plan to grow 3 times over,
some of us feel that we should use relative includes.

Example.
Say currently we have the directory structure
/cm/include
           /util
              u_list.h
           /foo
              f_fo.h
              f_foo.h
           /junk
              j_junkit.h
           etc.....

A c file would have
#include <stdio.h>
#include "f_fo.h"
#include "j_junkit.h"
main(){}

and a gcc line would be
   gcc -I/cm/include/util -I/cm/include/foo -I/cm/include/junk ...

I want to have the same directory structure as above but in the c file have.
#include <stdio.h>
#include "foo/f_fo.h"
#include "junk/j_junkit.h"
main(){}

and a gcc line would be
   gcc -I/cm/include ...

Any comments or suggestions are greatly welcomed (I will summarize if need be)
-- 
awick@csugrad.cs.vt.edu                             Andy Wick
awick@truffula.fp.trw.com                         Virginia Tech
It may be that your whole purpose in life, is to serve as a warning to others.
Technical Details
Message-ID: <21cukd$lbq@truffula.fp.trw.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!usc!venice!gumby.dsd.trw.com!truffula.fp.trw.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,cb9385093343e73,start
X-Google-Attributes: gid11318c,public
X-Google-Thread: fc89c,cb9385093343e73,start
X-Google-Attributes: gidfc89c,public
X-Google-ArrivalTime: 1993-07-06 16:12:52 PST
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!usc!venice!gumby.dsd.trw.com!truffula.fp.trw.com!not-for-mail
From: awick@truffula.fp.trw.com (Andy Wick)
Newsgroups: comp.unix.programmer,gnu.gcc.help
Subject: -I vs relative includes
Date: 6 Jul 1993 18:33:49 -0400
Organization: TRW Tactical Intelligence & Planning Systems
Lines: 46
Distribution: world
Message-ID: <21cukd$lbq@truffula.fp.trw.com>
NNTP-Posting-Host: truffula.fp.trw.com