Jump to content
  • Advertisement
Sign in to follow this  
Atash

GCC 3.4.2 lacking stream headers + probs in general w/ GCC

This topic is 4336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, technically, I'm not a newbie, because I'm already using VC++, however, I have an issue with GCC and getting it to work. I used to use Code::Blocks Rc1.0 which came with mingw installed, and had no problems with using ifstreams and ofstreams and the such. However, the standard library for the MinGW that I have just doesn't seem to work. I looked in the folders, and there was no ofstream file. Also, when I used fstream, the compiler came up with errors revolving around ios_base having a protected constructor and something about std::endl not existing. Is there any place I can download a more complete standard c++ library? Or, even better, am I doing something wrong and can I fix this without having to jump around the net? I've used google already but keep getting libstdc++, which comes directly with the GNU GCC and I can't exactly figure out how to make it all work out from source...

Share this post


Link to post
Share on other sites
Advertisement
- An ofstream file should not exist in any standard implementation (which version of VC++ are you using?!).
- ios_base has a protected constructor because you can't (read: shouldn't be able to) copy stream objects.
- std::endl is in <ostream>

Show the offending code, if you want a more complete answer.


jfl.

Share this post


Link to post
Share on other sites
#include <ofstream>

int main(int argc, const char* argv[])
{
//START DEBUG TEST

std::ofstream debug = std::ofstream("debug.txt");



That's really the only offending part. I believe I ought to be including something else, from what you said, but I'm just slightly confused as to how a string can be considered a stream and thus incite the copy constructor?

EDIT:
Heh, forgot something... I'm using VC++ 2005 Express as my IDE (to compile it without problems), and whatever version of VC++ that came with that.

Share this post


Link to post
Share on other sites
As I've said already, <ofstream> exists in neither stdlibc++, nor VC++8's standard implementation. It should be <fstream>.


As for the private constructor, you should have:

std::ofstream debug( "debug.txt" );

The section on explicit initialization (12.6.1) in the standard says that the code you have is the construction of a temporary followed by a copy. Compilers can decide to optimize the copy out, but you should assume they won't.


jfl.

Share this post


Link to post
Share on other sites
both of jflanglois's comments are 100% right ... just chiming in in case you don't believe him or something ...

it really helps to have a standard reference, or a good book on the standard library for finding out what things are supposed to be standard, and where they are. I like the Addison Wesley books in the C++, such as "The C++ Standard Library" ...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!