* g++ versus gcc
@ 2002-12-20 20:40 William Trenker
2002-12-21 1:47 ` LLeweLLyn Reese
2002-12-22 4:07 ` Ben Elliston
0 siblings, 2 replies; 3+ messages in thread
From: William Trenker @ 2002-12-20 20:40 UTC (permalink / raw)
To: gcc-help
(This has probably been asked a million times, but I did search the lists
and came up with only sketchy information.)
Today I upgraded my Linux 2.4.19 system from gcc 2.95.3 to gcc 3.2. I used
this test program:
#include <iostream>
struct test {
test(char* m) : msg(m) {};
char* msg;
};
main()
{
test* ptest = new test("Hello World");
cout << ptest->msg << endl;
};
To build this I used the time-honored: "gcc -o test test.cpp".
The build failed with the compiler complaining that "cout" and "endl"
weren't declared, and the linker grumbled that it couldn't resolve
references to "new", "delete", "cout", "basic_ostream" and other standard
objects.
A search on the mailing lists, and with Google, pointed out that I have to
explicitly decare namespace "std" -- gcc no longer defaults to "std".
Further searching suggested that I should be using "g++", not "gcc". Doing
both these things resulted in my little test program building and running
without error.
So now, it seems, we need to change all our makefiles, or the relevant
environment variables, to use "g++" instead of "gcc" for building c++ files.
I would appreciate confirmation that the use of "g++" has officially
replaced the use of "gcc" for c++ builds.
Thanks very much,
Bill Trenker
Kelowna BC Canada
_________________________________________________________________
MSN 8 with e-mail virus protection service: 3 months FREE*.
http://join.msn.com/?page=features/virus&xAPID=42&PS=47575&PI=7324&DI=7474&SU=
http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_eliminateviruses_3mf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: g++ versus gcc
2002-12-20 20:40 g++ versus gcc William Trenker
@ 2002-12-21 1:47 ` LLeweLLyn Reese
2002-12-22 4:07 ` Ben Elliston
1 sibling, 0 replies; 3+ messages in thread
From: LLeweLLyn Reese @ 2002-12-21 1:47 UTC (permalink / raw)
To: William Trenker; +Cc: gcc-help
"William Trenker" <wtrenker@hotmail.com> writes:
> (This has probably been asked a million times, but I did search the
> lists and came up with only sketchy information.)
>
> Today I upgraded my Linux 2.4.19 system from gcc 2.95.3 to gcc 3.2. I
> used this test program:
>
> #include <iostream>
> struct test {
> test(char* m) : msg(m) {};
> char* msg;
> };
> main()
> {
> test* ptest = new test("Hello World");
> cout << ptest->msg << endl;
> };
>
> To build this I used the time-honored: "gcc -o test test.cpp".
>
> The build failed with the compiler complaining that "cout" and "endl"
> weren't declared, and the linker grumbled that it couldn't resolve
> references to "new", "delete", "cout", "basic_ostream" and other
> standard objects.
>
> A search on the mailing lists, and with Google, pointed out that I
> have to explicitly decare namespace "std" -- gcc no longer defaults to
> "std". Further searching suggested that I should be using "g++", not
> "gcc". Doing both these things resulted in my little test program
> building and running without error.
>
> So now, it seems, we need to change all our makefiles, or the relevant
> environment variables, to use "g++" instead of "gcc" for building c++
> files.
No. Change them to use a variable - $(CXX) . Maintainable makefiles do
this anyway.
>
> I would appreciate confirmation that the use of "g++" has officially
> replaced the use of "gcc" for c++ builds.
I'm not an official gcc rep, but even with 2.95.3 I was never able to
get significant C++ prgrams to link without using 'g++'.
However I can't find explicit support for this in their
documentation. Spooky.
[snip]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: g++ versus gcc
2002-12-20 20:40 g++ versus gcc William Trenker
2002-12-21 1:47 ` LLeweLLyn Reese
@ 2002-12-22 4:07 ` Ben Elliston
1 sibling, 0 replies; 3+ messages in thread
From: Ben Elliston @ 2002-12-22 4:07 UTC (permalink / raw)
To: gcc-help
>>>>> "William" == William Trenker <wtrenker@hotmail.com> writes:
William> So now, it seems, we need to change all our makefiles, or the relevant
William> environment variables, to use "g++" instead of "gcc" for building c++
William> files.
William> I would appreciate confirmation that the use of "g++" has
William> officially replaced the use of "gcc" for c++ builds.
This has been the case for a long time, if not forever. g++ passes a
number of C++-specific options to the compiler and the linker that are
required for correct C++ compilation.
As for the issues with std::cout, G++ is always gravitating closer to
the C++ standard. Previously, it allowed non-conforming C++ programs
to build -- now it's time to fix the code.
William> Kelowna BC Canada
Lucky you. :-)
Ben
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-12-22 0:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-20 20:40 g++ versus gcc William Trenker
2002-12-21 1:47 ` LLeweLLyn Reese
2002-12-22 4:07 ` Ben Elliston
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).