www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/01/27/17:45:47

Message-ID: <20030127224518.94635.qmail@web13004.mail.yahoo.com>
Date: Mon, 27 Jan 2003 14:45:18 -0800 (PST)
From: Thomas Tutone <thomas8675309 AT yahoo DOT com>
Subject: Re: Newbie v2.03 missing error
To: djgpp AT delorie DOT com
Cc: beigebeing AT aol DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

"Beigebeing" <beigebeing AT aol DOT com> wrote:
> I am very new to c++, my problem is, my code works!
> djgpp v2.03 compiles this code,  when there should 
> be an error
> 
> #include <iostream>
>  int main(){
>  std::cout << "Hello"<< endl;    
>  return 0; }
> 
> Line 3 should be     std::cout << "Hello"<< 
> std::endl 
> 
> When I use the compile option in RHIDE, it compiles 
> reporting 'No errors'
> It also builds from a DOS command
>    gpp -o hello.exe hello.cpp 
> and runs fine.
> 

First, when you compile from the command line, get in
the habit of turning on all warnings - that will catch
a lot of errors where your code does not quite conform
to the standard:

gxx -W -Wall -pedantic -o hello.exe hello.cpp

That being said, whether I compile it the way I
suggest or the way you say you did it, I get the
following errors:

noerr.cpp: In function `int main()':
noerr.cpp:3: `endl' undeclared (first use this
function)
noerr.cpp:3: (Each undeclared identifier is reported
only once for each
   function it appears in.)

In other words, my compiler correctly refuses to
compile "endl" without putting "std::" in front of it.
 The fact that your compiler compiles it without
complaint leads me to believe that you are using a
fairly old version of djgpp - specifically one that
uses an old version of gcc.  (Perhaps you got it from
a book, rather than downloading it from the web.) 
Versions 2.95 and earlier departed from the C++
standard in a number of ways - among other things,
they did not enforce the use of the std namespace. 
Versions 3.0 and later do enforce this (correctly). 
The current version of gcc distributed with djgpp is
3.2.1.  To learn what version you have, type the
following at the command prompt:

gcc -v

On my computer, I get the following:

Reading specs from
c:/djgpp/lib/gcc-lib/djgpp/3.21/specs
Configured with:
/devel/gnu/gcc/3.2/gnu/gcc-3.21/configure
i586-pc-msdosdjgpp --
prefix=/dev/env/DJDIR --disable-nls
Thread model: single
gcc version 3.2.1

If your version of gcc is earlier than 3.0, you can
fix your problem by updating to the most recent
version.  To do that, go to:

http://www.delorie.com/djgpp/zip-picker.html

and download the latest version of djgpp.  DON'T just
update gcc and nothing else - you'll screw things up -
rather, get rid of your current installation of djgpp
entirely and install the current version of
everything, as explained in the directions you'll find
at the above url.

Once you've done that, your test program should
generate the error you expect.

Hope that helps.

Best regards,

Tom


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

- Raw text -


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