stupid g++ question
Jerry Feldman
gaf at blu.org
Thu Mar 14 12:59:44 EST 2002
You are right, here is the source I am concerned about:
#include <iostream.h>
#include <string>
int main()
{
string s;
s = "Hello, world!";
cout << s << "\n";
}
It was a cut/paste error, and I didn't catch it.
On 14 Mar 2002 at 11:45, John Jannotti wrote:
>
> I don't know the exact problem, but the error output you show is probably
> not from the shortened source that you show. It is complaining about
> identifiers (and line numbers) that don't exist in your source. Perhaps
> you shortened the source after generating the error?
>
> Certainly the source you show compiles fine for me under g++.
>
> shrub:~> cat hello.cc
> #include <iostream.h>
> int main()
> {
> cout << "Hello, world!" << "\n";
> }
> shrub:~> g++ hello.cc
> shrub:~> ./a.out
> Hello, world!
> shrub:~> g++ -v
> Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
> gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)
>
> jj
>
>
> "Jerry Feldman" <gerry.feldman at compaq.com> writes:
> > I have a simple hello world program that uses the string class. This
> > compiles and runs ok on some commercial c++ compilers but not on g++ (2.95
> > and 3.03). This is just one sanitized issue with a larger system.
> > #include <iostream.h>
> > int main()
> > {
> > cout << "Hello, world!" << "\n";
> > }
> > phbs.gf:src [158%] g++ hello.cc -o hello
> > hello.cc: In function `int main()':
> > hello.cc:5: `string' undeclared (first use this function)
> > hello.cc:5: (Each undeclared identifier is reported only once for each
> > function it appears in.)
> > hello.cc:5: parse error before `;' token
> > hello.cc:6: `s' undeclared (first use this function)
> >
> > phbs.gf:src [159%] cxx hello.cc -o hello
> > phbs.gf:src [160%] hello
> > Hello, world!
> >
> >
> > --
> > Jerry Feldman
> > Portfolio Partner Engineering
> > 508-467-4315 http://www.testdrive.compaq.com/linux/
> >
> > Compaq Computer Corp.
> > 200 Forest Street MRO1-3/F1
> > Marlboro, Ma. 01752
> >
> > _______________________________________________
> > Discuss mailing list
> > Discuss at blu.org
> > http://www.blu.org/mailman/listinfo/discuss
Jerry Feldman <gaf at blu.org>
Associate Director
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
More information about the Discuss
mailing list