Public Group

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

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

## 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 on other sites
- 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 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 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 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" ...

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 47
• ### Forum Statistics

• Total Topics
632636
• Total Posts
3007574
• ### Who's Online (See full list)

There are no registered users currently online

×