Bug 74946 - g++ on RH8.0 does not see standard library types properly
g++ on RH8.0 does not see standard library types properly
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-10-02 19:16 EDT by Matt Kennel
Modified: 2007-04-18 12:47 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-10-02 23:43:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Matt Kennel 2002-10-02 19:16:37 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020827

Description of problem:
For some reason in the g++ or libstdc++ installation the standard library types
do not seem to be visible to the compiler.  These are trivial programs which
work fine on Redhat 7.3.  This is serious since it is impossible to compile any
useful C++ program.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
% cat bug.cc
#include <sstream>
#include <string>

main() {
  string s("Hello standard library.\n"); 
  cout << "hello world\n" << s;

Actual Results:   g++ -o bug bug.cc
bug.cc: In function `int main()':
bug.cc:9: `string' undeclared (first use this function)
bug.cc:9: (Each undeclared identifier is reported only once for each function
   it appears in.)
bug.cc:9: parse error before `(' token
bug.cc:10: `cout' undeclared (first use this function)
bug.cc:10: `s' undeclared (first use this function)
[mbk@lyapunov ffs-adaptive]%

Expected Results:  % g++ -o bug bug.cc
% ./bug
hello world
Hello standard library.

Additional info:

g++ -v
[mbk@lyapunov ffs-adaptive]% g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
[mbk@lyapunov ffs-adaptive]%

% rpm -q -i gcc
Name        : gcc                          Relocations: (not relocateable)
Version     : 3.2                               Vendor: Red Hat, Inc.
Release     : 7                             Build Date: Tue 03 Sep 2002 08:04:33
Comment 1 Ali-Reza Anghaie 2002-10-02 23:43:15 EDT
For reference: 
[ali@damascus tt]$ cat /etc/redhat-release 
Red Hat Linux release 8.0 (Psyche) 
[ali@damascus tt]$ cat bug.cpp 
#include <iostream> 
#include <string> 
main() { 
        std::string s("Hello standard library.\n"); 
        std::cout << "hello world\n" << s; 
[ali@damascus tt]$ g++ -o bug bug.cpp 
[ali@damascus tt]$ ./bug 
hello world 
Hello standard library. 
Cheers, -Ali
Comment 2 Jakub Jelinek 2002-10-03 07:33:29 EDT
The standard defines string, cout etc. in std namespace.
So, either you do ali@packetknife.com suggested, or you add
using std::string;
using std::cout;
or you add
using namespace std;

Note You need to log in before you can comment on or make changes to this bug.