header/include files and compilers

header/include files and compilers

Post by Johnny Shi » Sun, 06 Jul 2003 10:11:21



Hi everyone,

When writing a program (say, work.c), I could simply include header
files using, for example:
#include <stdio.h>

and "gcc work.c" would compile no problem.

For the compiler such as gcc, how does it know where to find that
include file, without even having to specify paths to search using -I ?
  I'd certainly think it has internally included (default) path to
/usr/include/ ?  It also seems to be the case for arm-linu-gcc (cross
compiler for arm processor).  What if I do not want use those header
files in my native system but the others (ie. the ones that come with
arm cross compiler package)?

In addition, if two included paths both contain the header needed (same
name but not necessary the same content).  Which one does a compiler choose?

I never have understood this concept until recent I started working with
different compiler for different platform which has its own libraries
and different versions of linux kernels.  And I'd get confused with
different versions of header files in my system.

I'd really appreciate if anyone could answer these questions for me.
Thanks alot!

Johnny

 
 
 

header/include files and compilers

Post by Artie Gol » Sun, 06 Jul 2003 11:43:00



> Hi everyone,

> When writing a program (say, work.c), I could simply include header
> files using, for example:
> #include <stdio.h>

> and "gcc work.c" would compile no problem.

> For the compiler such as gcc, how does it know where to find that
> include file, without even having to specify paths to search using -I ?
>  I'd certainly think it has internally included (default) path to
> /usr/include/ ?  It also seems to be the case for arm-linu-gcc (cross
> compiler for arm processor).  What if I do not want use those header
> files in my native system but the others (ie. the ones that come with
> arm cross compiler package)?

> In addition, if two included paths both contain the header needed (same
> name but not necessary the same content).  Which one does a compiler choose?

> I never have understood this concept until recent I started working with
> different compiler for different platform which has its own libraries
> and different versions of linux kernels.  And I'd get confused with
> different versions of header files in my system.

> I'd really appreciate if anyone could answer these questions for me.
> Thanks alot!

Sure. If your using a flavor of gcc, do a `gcc -v'. The output will refer
to a `specs' file that will contain all such information.

HTH,
--ag

--
Artie Gold -- Austin, Texas

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

 
 
 

1. how to include C++ header files when using Forte 6 C++ compiler?

Hi, everyone,

We just installed Forte 6 and are testing its C++ compiler. We got following errors while trying to compile a small
code:

#include <iostream>
#include <string>

main()
{
      string C;
      cout << "hello\n";
      cin >> C;
      cout << "you typed: " << C << endl;

"testC.C", line 7: Error: string is not defined.
"testC.C", line 8: Error: cout is not defined.
"testC.C", line 9: Error: cin is not defined.
"testC.C", line 10: Error: cout is not defined.
"testC.C", line 10: Error: endl is not defined.
5 Error(s) detected.
-----------------------------------------------

If we use iostream.h, errors for cout,cin, and endl are gone. But undefined "string" error is always there no matter
whether <string> or <string.h> is used.

Any suggestions about how to include the header files?

Thanks for any help!

Wu

2. Unexplained Hanging

3. linux header files (include files)

4. NIS+ FAQ?

5. glibc header files or kernel header files?

6. Disk crash help needed.

7. AIX + gcc - include/header file problem

8. Recommend

9. solaris 2.x header/include file oddities!

10. GCC include header files

11. How to include header files and libraries in my program

12. Apache: server-side-includes in HEADER.html file

13. How to include header files in /net?