1

I am trying to compile some code using version 4.0 of Visual C++ Studio.

I understand that I need to use the standard template library for this code, here is where the compiler stops with an error:

#include <fstream>

fatal error C1083: Cannot open include file: 'fstream': No such file or directory

Looking at the compiler install disk the STL files are not installed with the compiler, but I found the subdirectory where they are on the install disk. I have never used the STL and am not sure where exactly to place the files. For now I have placed them in a subdirectory of my source files and added that directory to Build->Settings->Resources->Additional Resource Include Directories. Also note there is no file named fstream or fstream.h in the STL directory.

In the read.me is this note:

(1) STL is the container, iterator, algorithm part of the C++ standard library, it is not the complete standard library. (I/O streams, strings, etc. are not included in this package.)

So I am a bit confused - do I need to get additional source files somewhere, or how should I proceed? Thanks for any help!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
germ666
  • 11
  • 2
  • Welcome to Stack Overflow! I'm amazed anyone still has this compiler lying around. Are you working on a project where you must use VS4.0? If you can upgrade, I'd strongly suggest it. – templatetypedef Jul 07 '11 at 23:27
  • Yes I really should upgrade, but I like the simplicity and low overhead of this version. Thanks for the welcome. – germ666 Jul 07 '11 at 23:32
  • 2
    If humanly possible, upgrade to at least V4.2b. As of 4.0, you'll need *lots* of workarounds to get even an ancient version of STL to imitate working at all. 4.2b included a version that was reasonably adapted to the compiler (and, to my recollection, had quite a few other fixes as well). Unfortunately, 4.2b may be hard to find -- it was only ever shipped to people who bought a subscription. – Jerry Coffin Jul 07 '11 at 23:32
  • 1
    I do not have anything that antedeluvian, but I recall that the older STL includes still had the .h extension, try . – deinst Jul 07 '11 at 23:37
  • 1
    With the simplicity and low overhead, you also get massively ancient standards non-compliance, which is going to make it very difficult to work with 21st-century best practices... – Oliver Charlesworth Jul 07 '11 at 23:39
  • 2
    VC++4.0 was released in something like 94 or 95. That predates standardization by several years. You won't be coding in C++ as it exists today, so you're just going to be beating your head against the wall if you insist on this "simplicity." If you don't want a complex environment, code in Notepad, and compile with the current version... its free, you know. – Dennis Zickefoose Jul 07 '11 at 23:42
  • 2
    Looks like I'll be upgrading then, thanks for your help everyone. Seems that Visual Studio 2010 Express is free anyway so I'll give that a try. – germ666 Jul 07 '11 at 23:45
  • Well, if the only reason you were using 4.0 is because it's all you had, then YES, upgrade! 2010 Express is free, but even without that, there are several other compilers and IDEs that work fine on Windows, and are free. – jalf Jul 10 '11 at 08:59

1 Answers1

0

Visual C++ 4.0 is OLD!. It doesn't support STL properly. You should use at least use VC++ 6.0 (which does at least supports most of it) or better still use VC++ 2005 or 2008 express editions. Or you can use the GNU G++ compiler (through MinGW) which implements STL very nicely.

At the time VC++ 4.0 was made , C++ was not standardized (and STL is a subset of the C++ Standard Library) so it doesn't support most STL features or implements a non-standard version of them.

ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
  • STL != Standard Library. STL == Standard Template Library, a subset of the Standard Library. – Xeo Jul 10 '11 at 08:54
  • I **know**. But since the Standard Library was not standardized and the STL is a subset of the Standard Library , that means that the STL was not standardized too. – ApprenticeHacker Jul 10 '11 at 08:57