Topic: VC++, BC++, GNU C++


Author: John Lacey <johnl@vizdom.com>
Date: 1999/02/25
Raw View
Ross Smith wrote:
>
> Marecandja wrote in message <7aviga$rj9$1@news1.skynet.be>...
> >
> >    #include <iostream.h>
> >    #include <iomanip.h>
> >    #include <string>
>
> There's your problem. Mixing old-style and new-style headers isn't
> allowed in MSVC. Use <iostream> and <iomanip> instead. There's no
> such thing as <iostream.h> in standard C++. MSVC has an <iostream.h>,
> but it's only there to allow old code to be compiled, and isn't
> compatible with <iostream> or the rest of the standard C++ library.

For more information on this topic, see

 http://msdn.microsoft.com/visualc/stl/FAQ.HTM#Q3

I wanted to point out, however, that mixing the iostream library
and standard library in MSVC++ *is* allowed, and my experience is
that it mostly works just fine. It fails in two ways that are
documented (without much clarity) in the FAQ. First, the iostream
library doesn't support strings, and second, you can't mix the
iostream library with the standard iostreams.

I'm not recommending this practice. It is certainly non-standard,
but if you have old code that uses iostream.h, you don't have to
avoid the standard library, just the standard iostreams.

John L





Author: "Marecandja" <flop.m@usa.net>
Date: 1999/02/24
Raw View
Hi All,

Well, first of all, I'm a student, and I would like to know somethings
about compilers.

I had done some projects for university in Belgium. And since my first
project, I was working with G++. Now that I try to make some of those
projects under Windows, I can't get them build! It's pretty boring!

The first (and only for now :-) problem is the use of the class string.

For example, a function as simple as this one cannot be built under BC++
(5.0) & VC++ (6.0)

    #include <iostream.h>
    #include <iomanip.h>
    #include <string>                // <cstring> used under bc++
    #include "prj7_classes.h"    // part of my project
    #include "flat.h"                    //   "
    #include "owner.h"               // "
    #include "proper.h"              // "
    using namespace std;         // used only under vc++
./.
    void get_line(string &s)
    {
           cin >> ws;
           getline(cin, s);
     }

as well as a statement like this one

                cout << setw(2) << j << ". " << indice->address << endl;
with address of class string (and j of type int, but j is not the
problem)

Aren't Microsoft and Borland following the standard draft?
I'm learning C++ with a book 'C++ from the beginning' of Jan Skansholm,
and some little examples using the class string cannot be built under
those two compilers but works very well under g++.

Can someone tell me what to do? and why so many differences from a
compiler to another one? And which one follows the standard draft the
best? In other words, which one to use?

In fact, I wanted to be able to use those under windows because of the
good interface. But if there's something similar under Linux, I would
love to jump on!

Thanks to help me!
Issa Gorissen
Brussels Free University (ULB)




[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Ross Smith" <ross.s@ihug.co.nz>
Date: 1999/02/24
Raw View
Marecandja wrote in message <7aviga$rj9$1@news1.skynet.be>...
>
>For example, a function as simple as this one cannot be built under BC++
>(5.0) & VC++ (6.0)
>
>    #include <iostream.h>
>    #include <iomanip.h>
>    #include <string>

There's your problem. Mixing old-style and new-style headers isn't
allowed in MSVC. Use <iostream> and <iomanip> instead. There's no
such thing as <iostream.h> in standard C++. MSVC has an <iostream.h>,
but it's only there to allow old code to be compiled, and isn't
compatible with <iostream> or the rest of the standard C++ library.

Borland I can't help you with (although I suspect it's the same
problem).

>Aren't Microsoft and Borland following the standard draft?

Yes (at least in this case), so you need to follow it too.

--
Ross Smith ................................... mailto:ross.s@ihug.co.nz
.............. The Internet Group, Auckland, New Zealand ..............
         "The award for the Most Effective Promotion of Linux
         goes to Microsoft."             -- Nicholas Petreley
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]