public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: GCC compiler in Red Hat 9
@ 2004-01-12 20:05 lrtaylor
  0 siblings, 0 replies; 6+ messages in thread
From: lrtaylor @ 2004-01-12 20:05 UTC (permalink / raw)
  To: hasan.shibly, gcc-help

cout is in the "std" namespace.  So, you either need to add a "using namespace std;" statement after your include statement, or refer to cout as std::cout.

Cheers,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Hasan Shibly
Sent: Monday, January 12, 2004 12:57 PM
To: gcc-help@gcc.gnu.org
Subject: GCC compiler in Red Hat 9


Hello,

I have just installed Red Hat 9 (Fresh installation on a dual boot
system with Win XP) on my system.

For some reason g++ compiler is giving me errors, even for the simple
"Hello world" program.

#include <iostream>
int main()
{
cout << "hello world";
return EXIT_SUCCESS;
}

Below is the compilation error I am facing.

$ g++ test.cpp

test.cpp:5: 'cout' undeclared (first use this function)
test.cpp:5: (Each undeclared identifier is reported only once for each
function it appears in.)

Your help is highly appreciated.

Regards
H@z@n

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC compiler in Red Hat 9
  2004-01-12 20:11 ` Heiko Joerg Schick
@ 2004-01-13 14:01   ` Alexandre Oliva
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Oliva @ 2004-01-13 14:01 UTC (permalink / raw)
  To: Heiko Joerg Schick; +Cc: gcc-help

On Jan 12, 2004, Heiko Joerg Schick <info@schihei.de> wrote:

> 1. <iostream.h> is not part of standard C++. The 1998 C++ standard
> uses <iostream> (no ".h")

Actually, it is, but deprecated.  Its effect is equivalent to #include
<iostream> followed by using statements that bring in the declarations
from iostream into the global namespace.

> 2. Both <iostream> and <string> are in the "std" namespace.

Strictly speaking, header files are not in namespaces.  It's the
declarations they introduce that are.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Happy GNU Year!                     oliva@{lsd.ic.unicamp.br, gnu.org}
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC compiler in Red Hat 9
  2004-01-12 19:57 Hasan Shibly
  2004-01-12 20:06 ` Vu Pham
  2004-01-12 20:11 ` Heiko Joerg Schick
@ 2004-01-12 20:36 ` Eljay Love-Jensen
  2 siblings, 0 replies; 6+ messages in thread
From: Eljay Love-Jensen @ 2004-01-12 20:36 UTC (permalink / raw)
  To: hasan.shibly, gcc-help

Hi H@z@n,

Try this...

- - - - - - - - - - - - -

#include <iostream>
  using std::cout;
  using std::endl;
#include <cstdlib> // EXIT_SUCCESS

int main()
{
  cout << "Hello world" << endl;
  return EXIT_SUCCESS;
}

- - - - - - - - - - - - -

HTH,
--Eljay


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC compiler in Red Hat 9
  2004-01-12 19:57 Hasan Shibly
  2004-01-12 20:06 ` Vu Pham
@ 2004-01-12 20:11 ` Heiko Joerg Schick
  2004-01-13 14:01   ` Alexandre Oliva
  2004-01-12 20:36 ` Eljay Love-Jensen
  2 siblings, 1 reply; 6+ messages in thread
From: Heiko Joerg Schick @ 2004-01-12 20:11 UTC (permalink / raw)
  To: gcc-help

Hello Hasan,

I see several problems:

1. <iostream.h> is not part of standard C++. The 1998 C++ standard uses 
<iostream> (no ".h")

2. Both <iostream> and <string> are in the "std" namespace. To use 
anything in the standard namespace, you need to append "std::" before 
the function you are using (example std::cout instead of just cout)

Try:
---------------------------------------------------

  #include <iostream>
  
  int main()
  {
    std::cout << "hello world";
    return EXIT_SUCCESS;
  }
---------------------------------------------------

P.S.: The same with endl, goes to std::endl

Regards,
    Heiko

Hasan Shibly wrote:

>Hello,
>
>I have just installed Red Hat 9 (Fresh installation on a dual boot
>system with Win XP) on my system.
>
>For some reason g++ compiler is giving me errors, even for the simple
>"Hello world" program.
>
>#include <iostream>
>int main()
>{
>cout << "hello world";
>return EXIT_SUCCESS;
>}
>
>Below is the compilation error I am facing.
>
>$ g++ test.cpp
>
>test.cpp:5: 'cout' undeclared (first use this function)
>test.cpp:5: (Each undeclared identifier is reported only once for each
>function it appears in.)
>
>Your help is highly appreciated.
>
>Regards
>H@z@n
>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GCC compiler in Red Hat 9
  2004-01-12 19:57 Hasan Shibly
@ 2004-01-12 20:06 ` Vu Pham
  2004-01-12 20:11 ` Heiko Joerg Schick
  2004-01-12 20:36 ` Eljay Love-Jensen
  2 siblings, 0 replies; 6+ messages in thread
From: Vu Pham @ 2004-01-12 20:06 UTC (permalink / raw)
  To: hasan.shibly, gcc-help


----- Original Message ----- 
From: "Hasan Shibly" <hasan.shibly@saunalahti.fi>
To: <gcc-help@gcc.gnu.org>
Sent: Monday, January 12, 2004 1:57 PM
Subject: GCC compiler in Red Hat 9


> Hello,
> 
> I have just installed Red Hat 9 (Fresh installation on a dual boot
> system with Win XP) on my system.
> 
> For some reason g++ compiler is giving me errors, even for the simple
> "Hello world" program.
> 
> #include <iostream>
> int main()
> {
> cout << "hello world";
> return EXIT_SUCCESS;
> }
> 
> Below is the compilation error I am facing.
> 
> $ g++ test.cpp
> 
> test.cpp:5: 'cout' undeclared (first use this function)
> test.cpp:5: (Each undeclared identifier is reported only once for each
> function it appears in.)

Add "using namespace std;" after the #include <iostream>

HTH,

Vu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* GCC compiler in Red Hat 9
@ 2004-01-12 19:57 Hasan Shibly
  2004-01-12 20:06 ` Vu Pham
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hasan Shibly @ 2004-01-12 19:57 UTC (permalink / raw)
  To: gcc-help

Hello,

I have just installed Red Hat 9 (Fresh installation on a dual boot
system with Win XP) on my system.

For some reason g++ compiler is giving me errors, even for the simple
"Hello world" program.

#include <iostream>
int main()
{
cout << "hello world";
return EXIT_SUCCESS;
}

Below is the compilation error I am facing.

$ g++ test.cpp

test.cpp:5: 'cout' undeclared (first use this function)
test.cpp:5: (Each undeclared identifier is reported only once for each
function it appears in.)

Your help is highly appreciated.

Regards
H@z@n

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-13 14:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-12 20:05 GCC compiler in Red Hat 9 lrtaylor
  -- strict thread matches above, loose matches on Subject: below --
2004-01-12 19:57 Hasan Shibly
2004-01-12 20:06 ` Vu Pham
2004-01-12 20:11 ` Heiko Joerg Schick
2004-01-13 14:01   ` Alexandre Oliva
2004-01-12 20:36 ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).