Where "standard system include directory" is defined? (gcc)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Where "standard system include directory" is defined? (gcc)
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, ....."
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.
(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.
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.
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).
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")