www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/02/18/15:01:53

Message-ID: <20030218200121.65350.qmail@web13001.mail.yahoo.com>
Date: Tue, 18 Feb 2003 12:01:21 -0800 (PST)
From: Thomas Tutone <thomas8675309 AT yahoo DOT com>
Subject: Re: Strange compiler errors
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com


"Klytu" <jazzyjeff34 AT hotmail DOT com> wrote:

> Yesterday, during the blizzard here in Northeast 
> U.S., I installed the 
> latest DJGPP package (2.03)along with RHIDE and 
> gcc3.2.1 . I compiled 
> a program of mine that compiled with no errors 
> under the previous 
> package (2.02) and got error messages indicating 
> that the functions in 
> <cmath> were undefined. 

Without a short example (50 lines or less) that
reproduces the errors and the exact text of the error,
it is quite difficult to help.

> I did not include <cmath> directly but had the 
> following includes in my source:
> 
> #include <ctime>
> #include <cstdlib>
> #include <fstream>
> #include <iostream>

[snip]

> (A side problem I noticed is 
> that if I don't include <iostream>, I get errors 
> indicating that cout 
> and cin are undefined. I thought including 
> <iostream> after <fstream> 
> is already included was redundant or am I wrong 
> about that? 

You're wrong about that.   The standard requires that
std::cout and std::cin be defined in <iostream>.  It
is implementation-defined whether other headers
indirectly include the common code to define std::cout
and std::cin as well.  If you don't need std:cout or
std::cin and are only doing file i/o, then including
<fstream> should be sufficient.  But if you need to
use std::cin, std::cout, or std:cerr, then you must
include <iostream> for the program to be portable.

[snip]

> Basically everything was installed properly and I 
> changed 
> nothing (I might have changed the order of the 
> includes in my source, 
> but I am not sure). Suddenly everything compiles 
> with no errors now. I 
> would post the exact error messages I got if I 
> could remember them, 
> but suffice it to say that all the generated errors 
> were in indirectly 
> included files that were not in my source but in 
> the standard library. 
> Any explanation for this would be appreciated!

If you can't reproduce the errors, it's hard to
diagnose what the problem was.  But it's possible you
mixed deprecated and standard headers in the same
program (<stdlib.h> instead of <cstdlib> for example),
and that when you changed the order of the header
files, you also corrected that error.  But the
blizzard's knocked out my crystal ball, so I don't
know for sure.  If the problem returns, post some code
that reproduces it, along with the error messages.

Best regards,

Tom

__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

- Raw text -


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