delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/08/07/10:09:33

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Thu, 7 Aug 2003 10:09:19 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: "Zafrulla, Zahoor (Cognizant)" <ZZahoor AT chn DOT cognizant DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: Problem while compiling programs, using g++, which use the
string data type
In-Reply-To: <1449D1D9E1F9904484E66495141CA3C4070BFA@ctsintdlsxub.cts.com>
Message-ID: <Pine.GSO.4.44.0308071008040.5132-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

On Thu, 7 Aug 2003, Zafrulla, Zahoor (Cognizant) wrote:

> Hi,
>
> I have been trying to compile a set of files on the latest Cygwin DLL
> release under Win 2000. The same set of files compiles perfectly fine
> under red hat linux . In order to isolate the error i wrote a test
> program and i found tht ther is some problem with programs using the c++
> string data type. This is the program i tried and the result after
> compilation.
>
> ******************************************
> #include<string>
> #include<iostream.h>
>
> int main()
> {
>  string a = "Hello World!";
>  cout << a;
>  return 0;
> }
>
> *******************************************
>
> $ g++ -w -o test teststr.c
> teststr.c: In function `int main()':
> teststr.c:6: `string' undeclared (first use this function)
> teststr.c:6: (Each undeclared identifier is reported only once for each
>    function it appears in.)
> teststr.c:6: parse error before `=' token
> teststr.c:7: `a' undeclared (first use this function)
>
> ********************************************
>
> The test program compiles fine if i use g++-2 instead of g++. Is ther
> any particular option that i need to use ??
>
> Can anybody tell me what the problem is.
>
> Thanks,
> Zahoor Zafrulla

Gcc 3.2 is much stricter with namespaces than gcc 2.95 was.  Try using
"std::string" in your program, or put "using namespace std" at the top.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019