Thread: Re: [Dev-C++] #include <ios>
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2002-06-05 18:37:25
|
Why? don't understand why that is the solution. Unless there's more to the code than the one file. >From: "Bob Wilson" <bo...@ph...> >To: "Dev-C++ User Mailing List" <dev...@li...> >Subject: [Dev-C++] #include <ios> >Date: Wed, 5 Jun 2002 08:44:39 -0500 > > >I found the solution > > > I am working my way through Andrews Koenig's and Barbara E. Moo's book > > "Accelerated C++, Practical Programming by Example" and have a bit of a > > problem with an include file. The program starts: > > > > #include <iomanip> > > #include <iostream> > > #include <string> > > #include <ios> > > > > using std::cin; using std::setprecision; > > using std::cout; using std::string; > > using std::endl; using std::streamsize; > > > > Unfortunately I get the following error message: > > > > "ios: No such file or directory" > > > > MSVC .NET compiles it just fine. What am I missing? > > >It is: > >#include <iomanip> >#include <iostream> >#include <string> >#ifndef __GNUC__ >#include <ios> >#endif > >Regards, > >Bob Wilson > > > > >_______________________________________________________________ > >Don't miss the 2002 Sprint PCS Application Developer's Conference >August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. |
|
From: Bob W. <bo...@ph...> - 2002-06-05 19:16:26
|
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 ************************* > >From: "Bob Wilson" <bo...@ph...> > >To: "Dev-C++ User Mailing List" <dev...@li...> > >Subject: [Dev-C++] #include <ios> > >Date: Wed, 5 Jun 2002 08:44:39 -0500 > > > > > >I found the solution > > > > > I am working my way through Andrews Koenig's and Barbara E. Moo's book > > > "Accelerated C++, Practical Programming by Example" and have a bit of a > > > problem with an include file. The program starts: > > > > > > #include <iomanip> > > > #include <iostream> > > > #include <string> > > > #include <ios> > > > > > > using std::cin; using std::setprecision; > > > using std::cout; using std::string; > > > using std::endl; using std::streamsize; > > > > > > Unfortunately I get the following error message: > > > > > > "ios: No such file or directory" > > > > > > MSVC .NET compiles it just fine. What am I missing? > > > > > >It is: > > > >#include <iomanip> > >#include <iostream> > >#include <string> > >#ifndef __GNUC__ > >#include <ios> > >#endif > > > >Regards, > > > >Bob Wilson > > > > > > > > > >_______________________________________________________________ > > > >Don't miss the 2002 Sprint PCS Application Developer's Conference > >August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm > > > >_______________________________________________ > >Dev-cpp-users mailing list > >Dev...@li... > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. > |
|
From: Ioannis V. <no...@ho...> - 2002-06-05 22:38:18
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Bob Wilson > Sent: Wednesday, June 05, 2002 10:16 PM > To: Dev-C++ User Mailing List > Subject: Re: [Dev-C++] #include <ios> > > I suspect there is an incompatibility with the compiler which > the authors > discovered. Yes it is. But try to not think of that, but wait till MINGW 3.x . Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: Bob W. <bo...@ph...> - 2002-06-06 00:40:36
|
Ioannis, > Yes it is. But try to not think of that, but wait till MINGW 3.x . Believe me, I am waiting with baited breath! Regards, Bob |
|
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.) |
|
From: Bob W. <bo...@ph...> - 2002-06-06 00:32:48
|
Mac, > 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. That would be my guess. The book was copyrighted in 2000. > **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. For the simplist programs, however, there should not be any modifications required. Just out of curiosity, do you know of a "knowledge base" that summarizes the changes that are often reuired from compiler to compiler? > 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). I am in the process of learning STL programming hand-in-hand with "Accelerated C++". Thanks for the link to "stlport.org"! > Since you are learning from that book, you may want to check out: > > http://www.acceleratedcpp.com/ Thanks again. I had visited that site before but could not find it again. Regards, Bob |
|
From: Ioannis V. <no...@ho...> - 2002-06-08 02:29:59
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Bob Wilson > Sent: Thursday, June 06, 2002 3:33 AM > To: Dev-C++ User Mailing List > Subject: Re: [Dev-C++] #include <ios> > > > **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. > > For the simplist programs, however, there should not be any > modifications > required. Just out of curiosity, do you know of a "knowledge > base" that > summarizes the changes that are often reuired from compiler > to compiler? Not for the simplest only. There is no need for such a knowledge base, because ANSI C++ conformance will be improving continually. Do not think that there will remain gray areas at the end, as for ANSI SQL conformance for example. There are already compilers with 100% conformance. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-06-08 02:45:30
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Mac Reiter > Sent: Thursday, June 06, 2002 12:00 AM > To: Dev-C++ User Mailing List > Subject: Re: [Dev-C++] #include <ios> > > > 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. > <ios> is needed when you want to use the facilities icnluded in it. You can not depend if a header file is included in another when not defined by the standard (if you wat the code to be portable, not even among different compilers and platforms, but even to the next version of your favorite compiler). You *must not* care about implementation details inside your code, and certainly not connect your code with them. It is the compiler's job for what headers it #include s inside other header files. > 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. No the book is ANSI C++ compliant (at least as far as i know, and C++ god approves it, and god only approves excellent ANSI C++ compliant books). > > **IMPORTANT NOTE FOR NEW C++ PROGRAMMERS ** > Also, there is no such thing as an "ANSI C++ compliant > compiler" Of course there is. Try Intel C++ compiler for example. > -- *all* > current compilers fail the conformance tests in various ways. Not all. And standard conformance is increased day by day to the rest compilers too. Camaeu is another 100% conformant compiler too. And there are probably others too (perhaps GCC 3.x is 100% compliant too). > This means > that sample code inevitably needs to be modified for > different compilers. Things are improving day by day. The standard is very recent (late of 1998) for *everything* to be implemented immediately. And C++ is a multiparadigm language, that means it is like 4+ languages together (4 paradigms and many space/time efficiency concerns since it is intended for mission critical applications too (OSes, etc). > "Portable" code, for the time being, requires preprocessor > directives like > the one shown to change the code based on which compiler is > being used. No. Simply you code for the compiler you intend to use thinking of full ansi C++ and then if something does not compile, you change it with something that does. If you write a library or something and you care for many compilers out there, i wouldn't care but code as freely as i can knowing that since things are improving day by day everything will be soon ok for them too. That is, i can't think of an occasion why i would need #ifndefs for portability, and i can't think for any possible reason to do so. #ifndefs are used to make portable code using compiler extensions not for ANSI C++ code.Ioannis I think you have confused ANSI C++ code with system specific code (e.g. Win32 library calls). * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |