Networking Forums

Networking Forums > Computer Networking > Linux Networking > #include <some_file.h>

Reply
Thread Tools Display Modes

#include <some_file.h>

 
 
Dan
Guest
Posts: n/a

 
      07-22-2005, 02:21 AM

This is a bit off topic, but this newsgroup seems to be read by the
most knowledgable people. Suggestions for a better group would be
appreciated.

When you look in the kernel source code, or any source code for that
matter, you see include files surrounded by angle brackets. I've
always thought of them as meaning 'look for the file in the spot where
such files are usually kept'. Where and how is this defined? And
with regards to a kernel build, where are these files exactly? Is
this always defined by the compiler? In a kernel build, do they also
point to files in the kernel source?

Dan
 
Reply With Quote
 
 
 
 
Lew Pitcher
Guest
Posts: n/a

 
      07-22-2005, 03:32 AM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dan wrote:
> This is a bit off topic, but this newsgroup seems to be read by the
> most knowledgable people. Suggestions for a better group would be
> appreciated.
>
> When you look in the kernel source code, or any source code for that
> matter, you see include files surrounded by angle brackets. I've
> always thought of them as meaning 'look for the file in the spot where
> such files are usually kept'.


That's a good summary of what the C standard says about #include <>
> Where and how is this defined?


It is system dependant. It is defined by how the C compiler environment in your
system is specified to be set up. The lookup is /implemented/ in the C
compiler, in accordance with the specifics of the environment. In Unixish
systems like Linux, the <> files are 'looked for' in the /usr/include directory
tree.

> And
> with regards to a kernel build, where are these files exactly?


/usr/include/linux and /usr/include/asm and a few other directories under the
/usr/include tree

Hint: the value within the <> is a path relative to /usr/include
For instance
#include <asm/uaccess.h>
includes the file /usr/include/asm/uaccess.h, while
#include <linux/config.h>
includes the file /usr/include/linux/config.h


> Is
> this always defined by the compiler? In a kernel build, do they also
> point to files in the kernel source?


They could, with #include "local/path", but apparently they dont
The kernel headers in /usr/src/linux seem to be copied or linked to the headers
in /usr/include/linux, etc.

> Dan



- --
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC4GjnagVFX4UWr64RAuIUAJ4w+sNoqKNluzhdg3UpPb bsEOTuPgCgqbT4
uuVGiqN04TsI/NAnDNPtEMc=
=SKaa
-----END PGP SIGNATURE-----
 
Reply With Quote
 
Dan
Guest
Posts: n/a

 
      07-22-2005, 04:08 AM
On Thu, 21 Jul 2005 23:32:55 -0400, Lew Pitcher
<(E-Mail Removed)> wrote:

Thanks for that.

I'm trying to cross compile a kernel for an embedded target and am
getting lots of 'can't find file' errors. Do you know if there's some
way to point the compiler to the right kernel source, or at least find
out where it's pointing?

Dan

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Dan wrote:
>> This is a bit off topic, but this newsgroup seems to be read by the
>> most knowledgable people. Suggestions for a better group would be
>> appreciated.
>>
>> When you look in the kernel source code, or any source code for that
>> matter, you see include files surrounded by angle brackets. I've
>> always thought of them as meaning 'look for the file in the spot where
>> such files are usually kept'.

>
>That's a good summary of what the C standard says about #include <>
>> Where and how is this defined?

>
>It is system dependant. It is defined by how the C compiler environment in your
>system is specified to be set up. The lookup is /implemented/ in the C
>compiler, in accordance with the specifics of the environment. In Unixish
>systems like Linux, the <> files are 'looked for' in the /usr/include directory
>tree.
>
>> And
>> with regards to a kernel build, where are these files exactly?

>
>/usr/include/linux and /usr/include/asm and a few other directories under the
>/usr/include tree
>
>Hint: the value within the <> is a path relative to /usr/include
>For instance
> #include <asm/uaccess.h>
>includes the file /usr/include/asm/uaccess.h, while
> #include <linux/config.h>
>includes the file /usr/include/linux/config.h
>
>
>> Is
>> this always defined by the compiler? In a kernel build, do they also
>> point to files in the kernel source?

>
>They could, with #include "local/path", but apparently they dont
>The kernel headers in /usr/src/linux seem to be copied or linked to the headers
>in /usr/include/linux, etc.
>
>> Dan


 
Reply With Quote
 
Juha Laiho
Guest
Posts: n/a

 
      07-24-2005, 06:25 AM
Dan <(E-Mail Removed)> said:
>On Thu, 21 Jul 2005 23:32:55 -0400, Lew Pitcher
><(E-Mail Removed)> wrote:
>
>Thanks for that.
>
>I'm trying to cross compile a kernel for an embedded target and am
>getting lots of 'can't find file' errors. Do you know if there's some
>way to point the compiler to the right kernel source, or at least find
>out where it's pointing?


Include files are handled by the preprocessor, so read the preprocessor
specific parts of "info gcc" documentation. A good starter is the
preprocessor option summary (in Invoking GCC node of the document),
with e.g. the following:
`-I DIR'
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, the option is ignored to
ensure that the default search order for system directories and
the special treatment of system headers are not defeated .

`-I-'
Split the include path. Any directories specified with `-I'
options before `-I-' are searched only for headers requested with
`#include "FILE"'; they are not searched for `#include <FILE>'.
If additional directories are specified with `-I' options after
the `-I-', those directories are searched for all `#include'
directives.

In addition, `-I-' inhibits the use of the directory of the current
file directory as the first search directory for `#include "FILE"'.

-isystem DIR'
Search DIR for header files, after all directories specified by
`-I' but before the standard system directories. Mark it as a
system directory, so that it gets the same special treatment as is
applied to the standard system directories.

--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
 
Reply With Quote
 
Dan
Guest
Posts: n/a

 
      07-25-2005, 01:12 AM
On Sun, 24 Jul 2005 06:25:47 +0000 (UTC), Juha Laiho
<(E-Mail Removed)> wrote:


>Include files are handled by the preprocessor, so read the preprocessor
>specific parts of "info gcc" documentation.


Thanks for that, I'll have a look.

Dan

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
include port in hosts file John A Grandy Windows Networking 1 04-15-2009 01:04 PM
V21 Changes T&Cs to include £70 Termination fee? Toaster Broadband 1 10-21-2006 09:37 AM
Does DD-WRT include a Client Mode? DaveC Wireless Internet 1 05-04-2005 05:52 AM
GPO to include .exe file =?Utf-8?B?TFk=?= Windows Networking 1 01-20-2005 08:57 AM
Wireless Connection to Include PS2? Chris Burson Broadband 2 03-07-2004 04:59 PM



1 2 3 4 5 6 7 8 9 10 11