www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/04/14:54:17

Date: Fri, 4 Sep 1998 13:46:11 -0500 (CDT)
From: JAU-BING LIN <jl1013 AT broncho DOT ucok DOT edu>
To: DJGPP Mailing List <djgpp AT delorie DOT com>
Subject: RE: Why doesn't C++ work!?!?!
In-Reply-To: <000101bdd7f0$3648b760$ca4e08c3@arthur>
Message-ID: <Pine.A32.3.91.980904133822.79390B-100000@broncho.ucok.edu>
MIME-Version: 1.0


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 <iostream.h>
> >
> > 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 <iostream.h>
> 
> 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.

- Raw text -


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