LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-20-2006, 09:12 PM   #1
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,436

Rep: Reputation: 83
Question Where "standard system include directory" is defined? (gcc)


Hi, Penguins.

BIG APOLOGIES for pre beginner question.

This penguin got totally confused.

With gcc (linux), "man gcc" says -I/search/directory/ "Add the directory dir to the list of directories to be searched for header files. Directories named by -I are searched before the standard system include directories. If the directory dir is a standard system include directory, ....."

http://gcc.gnu.org/onlinedocs/gcc/Di...y-Options.html says similar thing and several environment variables.

Then, confusion comes, "which directory is standard system include directory" where is definition?
I am very sure (although not 100%) /usr/include is one of them.

Where can I find definition of "standard system include directory(is)?

HUGE APOLOGIES again
 
Old 07-20-2006, 09:27 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

You're 100% correct - "/usr/include" is the standard "system directory" under Unix and Linux.

"/usr/local/include" is another Pop Favorite.

Under Windows, Visual Studio sets environment variables like %INCLUDE%, %LIB% and %MSVCDir%.

As you saw in the link you quoted, GCC also allows you to set environment variables, like $CPATH, $C_INCLUDE_PATH and $CPLUS_INCLUDE_PATH:
http://gcc.gnu.org/onlinedocs/gcc/En...ment-Variables

Last edited by paulsm4; 07-20-2006 at 09:30 PM.
 
Old 07-20-2006, 10:02 PM   #3
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,436

Original Poster
Rep: Reputation: 83
Thanks for prompt reply.

This question came from "is /usr/local/include" standard system include directory?

I do not know anything about evil bill's junk. Old Macintosh used to use #include <this.h> for whatever found InsideMac (Apple defined), #include "that.h" for user defined ones.... Pascal was the official language, C was a dialect.
 
Old 07-21-2006, 09:49 AM   #4
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
(Note that this is all based on GCC 3.3.3 and GCC 3.4.4 because those are the only versions I have installed. The -isystem option is not documented in my GCC 3.4.4 manpage but it still works. As far as GCC > 3.4 goes you're on your own I'm afraid.)

With various options (such as -I and -I- and -isystem) you can specify lots of different inclusion features. Basically, directories specified by -I will be searched before those specified by -isystem, which will in turn be searched before those in the "standard system include directories" (at least, according to my tests). The difference is that -I can be used for any #include directive, but -isystem will only be used for #include <...> That said, though, it is recommended to only use -I for #include "..." directives because of the search order. Using -I- really gives you a lot of control because any -I used before -I- will be searched for only for #include "..." whilst any -I used after -I- will be searched for any #include directive. In addition, using -I- means that the current directory will not be searched for included files unless you also specify -I. (search the current directory).

If you want to get a listing of what search directories are supported by default, try running this command: `cpp -v < /dev/null` This runs the GNU C Preprocessor with no input; in the process it will print (given the -v flag) the inclusion directory search paths. You should see phrases like "#include <...> search starts here:" followed by a list of directories. Those are your standard inclusion search paths, in the order that they're searched.

In most cases, you will specify which inclusion directories you want searched with the appropriate options to GCC from a Makefile or the like. If you specify a directory that's already given, there's no problem because it will simply be ignored. So almost 100% of the time it's not really necessary to know what the default search directories are. Aside from running cpp with no input, like I say above, I don't know that there's any way to tell what the defaults are. Also, I don't know when they're specified - probably at compile time, but I don't know where or how. Hope this helps you somewhat.

Oh, and you are absolutely correct about the difference between #include "..." and #include <...> Although, since it's only a matter of how directories specified as arguments to the preprocessor are searched, I think it's really more style and form than anything technical. That said, we should all probably continue to stick to the convention of separating code we wrote specifically for the given project from general system inclusion files that anybody might use for anything.
 
Old 07-21-2006, 10:12 AM   #5
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,436

Original Poster
Rep: Reputation: 83
Thanks a lot.

Yes, your explanation helped a little bit more than somewhat.

I am working on tarball which chokes while compile. To make things worse, I have almost zero experience with inside "make" and "configure", althugh I used many times.

Now, I know how I can find which include file went through default path, and which went through -I or whatever.

Actually, I checked ANSI book and found that #include <your_code> searches your_code in system (system dependent manner) and that #include "my_code" looks for my_code in my directory (system dependent manner). So, it is ANSI standard.
 
Old 07-21-2006, 11:37 AM   #6
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, again -

1. More informally:
Quote:
a) #include <SOME_SYSTEM_HDR.H>
<= THIS APPLIES TO STUFF THAT COMES WITH THE COMPILER
YOU SHOULD *NOT* TYPICALLY NEED EXPLICIT "-I" COMPILE FLAGS
Quote:
b) #include "SOME_APP_HDR.H"
<= THIS IS YOUR OWN STUFF
YOU ALMOST ALWAYS NEED "-I..." TO FIND THESE
2. As far as your original question, "/usr/include" and "/usr/local/include" are the two "system header paths" where you DON'T usually need to specify a "-I..." include path.

You can modify the "system header path" with compiler-dependent variables like $C_INCLUDE_PATH and $CPLUS_INCLUDE_PATH.

3. Feel free to post specific compile errors and ask how you might fix them. It might be best to create a new thread each time you ask a new, different question.

Be sure to cut/paste the specific error message, and be sure to put them in "[quote]" or in "[code]" blocks.

'Hope that helps .. PSM
 
Old 07-21-2006, 01:49 PM   #7
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,436

Original Poster
Rep: Reputation: 83
Thank you for your additional information.

However, I need to know either yes/no answer if /usr/local/include is "standard system include directory" on my penguin (gcc404). More specific, at some spot during "make all" process (10min+ output is long).

So far,
1. -I/search/this/directory does not affect "standard system include directory".
2. My penguin does not have any shell environment, which affect include path. (I still do not know if "standard ..... directory" is altered by these environment.)
3. thus, I assume whatever directories "cpp -v < /dev/null" returns are "standard ... directories at shell prompt.
4. 3. is also true during make process. (no setenv, export during the process.)
5. I also need to figure out what "special treatment of system headers" is. (found in "man gcc")
 
Old 07-22-2006, 09:30 PM   #8
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,436

Original Poster
Rep: Reputation: 83
I think "special treatment of system headers" means that they are immune to some warnings.
http://gcc.gnu.org/onlinedocs/gcc-3....stem%20Headers

Am I correct?
 
Old 07-23-2006, 08:22 AM   #9
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
related thread

This thread came up recently, I think it may give you some more information, even though it does sort of contradict the result of the `cpp -v < /dev/null` thing: http://www.linuxquestions.org/questi...d.php?t=466499
 
  


Reply

Tags
gcc, include


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"bad interpreter : no such file or directory" when configure "flex" acer_peri Linux - Software 10 11-10-2010 01:19 AM
Porting to Fedora gcc 4.0 -parsing backward slash("\") comma(",") code_blew Programming 1 04-26-2006 04:07 PM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM
"mkdir: cannot create directory `foo': Read-only file system" on FAT32 maddes Linux - Hardware 1 11-26-2003 06:19 PM
i just finished typing "./configure" and "make" in mplayer directory... kublador Linux - General 4 02-22-2003 03:12 PM


All times are GMT -5. The time now is 08:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration