Date: Fri, 4 Sep 1998 13:46:11 -0500 (CDT) From: JAU-BING LIN To: DJGPP Mailing List Subject: RE: Why doesn't C++ work!?!?! In-Reply-To: <000101bdd7f0$3648b760$ca4e08c3@arthur> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Fri, 4 Sep 1998, Arthur wrote: > > Hey guys: > > > > I have not been able to get any C++ programs compiled - and on the DJGPP > > website, it says that gcc should know what to to with the file according > > to the file's extenstion. I tried to compile a simple C++ program that > > couts one line (it looks like this): > > > > #include > > > > main(void) > > { > > cout << "This is a test."; > > } > > C++ is VERY picky about implicit declarations. It will throw a wobbley if > you don't define main() as int main() (any function parameters not declared > will be counted as void in C++, but not in C). main() always returns an int > (even in C), but C won't shout at you half as much as C++ will. Also note > that at the end of the program you must have a return 0; or something to > shouw that it exits properly. > > And more picking with your code. C++ standards state that you should output > an endl at the end of each line you stream to the stdout. > > gcc will not link with the C++ libraries according to extension. To do this > you must use gxx (which will). > > So your code should be: > > #include > > int main() > { > cout << "This is a test." << endl; > return 0; > } > > and then compile it with gxx. > > HTH > > James Arthur > jaa AT arfa DOT clara DOT net > ICQ#15054819 Actually, I trided the program last night. I use RHIDE to edit the code and run it. I did not put "int" in front of main(). Also I did not put "return 0;" at the last line in my code. However, the program is still working find.