This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

g++ versus gcc


(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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]