[ale] basic gcc compiler issues...

Stephen Leonard stephen at phynp6.phy-astr.gsu.edu
Thu Jan 8 09:30:26 EST 2004


On Thu, Jan 08, 2004 at 08:43:50AM -0500, Keith Morris wrote:
> After many years away from an elementary knowledge of C and C++ I have
> gone back into self training mode, but this is the first time on Linux
> and am having a basic compiler problem...
> 
> given this program:
> 
> #include <iostream.h>
> 
> int main() {
> 
>   cout << "Hello, World!" << endl;
>   return 0;
> 
> }
>  g++ hello.cpp -o hello compiles correctly, but gives me the following
> warning (which I understand):
> 
> In file included from /usr/include/c++/3.3.2/backward/iostream.h:31,
>                  from hello.cpp:1:
> /usr/include/c++/3.3.2/backward/backward_warning.h:32:2: warning:
> #warning This file includes at least one deprecated or antiquated
> header. Please consider using one of the 32 headers found in section
> 17.4.1.2 of the C++ standard...
> 
> so, reading the standard, if I change the program to:
> 
> #include <iostream>
> ...
> 
> the compiler gives me this error:
> hello.cpp: In function `int main()':
> hello.cpp:5: error: `cout' undeclared (first use this function)
> hello.cpp:5: error: (Each undeclared identifier is reported only once
> for each function it appears in.)
> hello.cpp:5: error: `endl' undeclared (first use this function)
> 
> 
> I am on Fedora Core 1 and checking the rpm database, all seems to be
> installed for C++ console development. Am I missing the standard
> libraries?  I can't figure it out. Also, it is doing this on both of the
> Fedora machines I have set up.

I think you need the following declaration below your include macros.

using namespace std;

Or you could use the prefix 'std::cout' and 'std::endl', but that'll
get a little tedious.

stephen



More information about the Ale mailing list