|
From: Mac R. <re...@no...> - 2002-06-05 21:01:12
|
Daniel: The <ios> header is generally not needed, and should have been included by other iostreams headers. I suspect that the GCC or MinGW people simply removed the standalone header, or perhaps it is present but can only be found if you specify <ios.h> instead of just <ios>. (The <ios.h> is *purely* a guess and I haven't run any checks at all). Since Dev-C++ is "just" the editor/debugger/project manager, and it uses the GCC/MinGW toolchain for actual compilation, these kinds of issues will depend entirely on how the GCC/MinGW tools work. Microsoft's take on <ios> is given in the following MSDN article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/ht ml/vclrfios_header.asp Basically, you could simply remove the <ios> line entirely, and both compilers would be happy and you wouldn't need the preprocessor commands ("ifndef", etc). I'm gonna guess that the book was written some time ago, some of the C++ standards changed along the way, and not all of the sample code got updated. **IMPORTANT NOTE FOR NEW C++ PROGRAMMERS ** Also, there is no such thing as an "ANSI C++ compliant compiler" -- *all* current compilers fail the conformance tests in various ways. This means that sample code inevitably needs to be modified for different compilers. "Portable" code, for the time being, requires preprocessor directives like the one shown to change the code based on which compiler is being used. This is an excellent reason to learn STL programming, because the nastiest "adjustments" have already been done for you by the STL implementation, especially if you use something like STLport (www.stlport.org). **IMPORTANT NOTE FOR NEW C++ PROGRAMMERS ** Since you are learning from that book, you may want to check out: http://www.acceleratedcpp.com/ for updates and hints for adjusting the code to various compilers. Since GCC/MinGW is based on GCC for Unix, if you download the source code samples you will want to download the Unix sources, not the Visual C++ files. Don't let the "tar file compressed with gzip" bother you -- WinZip will unpack it just like a ZIP file. It will have one intermediate step where it extracts the TAR file from the GZIP file, and then extracts the real files from the TAR file. Just answer "yes" to the question box and it will work fine. If any of the source code is Windows specific, you may just need to try all three sets of Windows sample code (VC6, VC.net, and Borland). Good luck, Mac At 02:16 PM 6/5/02 -0500, Bob Wilson wrote: >Daniel, > > >> Why? don't understand why that is the solution. >> Unless there's more to the code than the one file. > >Perhaps a little background is in order. I typed the programs in directly >from the text and was presented with the error previously discussed, i.e., >the compiler could not find an "ios" file to include. When I commented that >compiler command line out, the program compiled and ran just fine. While >searching around for an answer, I came across the source files for the book >on the Internet. The program upon which I was working had the "#ifndef" and >"#endif" bookends to the "#include <ios>" statement. When I modified my code >that way, the program compiled and ran just fine. > >I suspect there is an incompatibility with the compiler which the authors >discovered. > >Regards, > >Bob - _____________________________ /"\ Mac Reiter \ / ASCII Ribbon Campaign Nomadics, Inc. X Against HTML Mail re...@no... / \ (To join the campaign, simply use this in your signature.) |