GCC -3.1 problem with header files

Oscar Fuentes ofv@wanadoo.es
Mon May 27 14:16:00 GMT 2002


Steve Ettorre <sme@nycap.rr.com> writes:

> Hi all-
> 
> I have what I think is probably a stupid error on my part, but I could
> use some help. A simple test code such as "test.C":
> 
> #include <iostream>

using namespace std;  // <<--------------
 
> int main() {
>     cout << " Main: running..." << endl;
>     return 0;
> }

or

     std::cout << " Main: running..." << std::endl;

> 
> will not compile with GCC 3.1. I get the following errors:
> 
> test.C: In function `int main()':
> test.C:4: `cout' undeclared (first use this function)
> test.C:4: (Each undeclared identifier is reported only once for each
> function    it appears in.)
> test.C:4: `endl' undeclared (first use this function)
> 
> 
> Obviously, g++ is not seeing the proper system "include" directory
> which on my RedHat system is: /usr/include/g++-v3.

Yes. <iostream> differs from the old non-standard <iostream.h> on that
it declares the identifiers in namespace std (as all Standard C++
Library does).

BTW, be sure you build with 'g++', not 'gcc'.

> What do I have to do to get GCC 3.1 to see the "include" directories?
> 
> TIA,
> Steve
> 

-- 
Oscar



More information about the Gcc-help mailing list