473,506 Members | 17,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iostream + iostream.h

Hi,

probably this is a common problem but I couldn't find yet a proper
solution (and I hope there is one).

I have two relative complex frameworks: one uses only iostream.h the
other one only iostream.
Is it somehow possible to put them together to one framework and solve
the iostream problem (also other header are effected, e.g. fstream)?
If I just change the header in one framework I get lots of errors,
which are very difficult to fix (at least for me).

It's really important so I'm happy for every help.
Thanks,

S. Nurbe
Jul 22 '05 #1
7 3189
"S. Nurbe" <re*******@yahoo.de> wrote...
probably this is a common problem but I couldn't find yet a proper
solution (and I hope there is one).

I have two relative complex frameworks: one uses only iostream.h the
other one only iostream.
Is it somehow possible to put them together to one framework and solve
the iostream problem (also other header are effected, e.g. fstream)?
If I just change the header in one framework I get lots of errors,
which are very difficult to fix (at least for me).


Perhaps it's not going to be of much help, but believe me, you will be
so much better off if you just bite the bullet and fix all the errors
you get when you change the header to <iostream>. <iostream.h> is not
a standard header, basically not supported any more, old and ugly, and
sometimes slow or buggy. Tell your boss you need a couple of days to
clean all this mess up, and just do it.

Difficult does not mean impossible. You will learn a great deal while
making those fixes. Not only you will have a working system based on
the standard library, you will gain experience on code cleanup and in
dealing with fragile legacy frameworks the right way.

Best of luck!

V
Jul 22 '05 #2
S. Nurbe wrote:
probably this is a common problem but I couldn't find yet a proper
solution (and I hope there is one).
I think this issue was discussed several times in past in this
forum though you might not like the answers.
I have two relative complex frameworks: one uses only iostream.h the
other one only iostream.
Is it somehow possible to put them together to one framework and solve the iostream problem (also other header are effected, e.g. fstream)?
Put very plain and simple: there is *NO* way to mix code compiled
with these headers. You have no other choice than transforming the
code using the ".h" version into code which does not use them. One
of the problems is that the libraries share certain common symbols
for objects with different object layouts.
If I just change the header in one framework I get lots of errors,
which are very difficult to fix (at least for me).


You should not just change the header but also add a using directive.
For example:

| #include <iostream.h>

should become

| #include <iostream>
| using namespace std;

The using directive is generally frowned upon, especially if it is
put into headers, but for a short-term approach to the conversion
it is essentially the only viable approach. On approach which often
works and eases the transistion is to provide your own version of
the .h-headers which essentially look something like below:

| // mystd/iostream.h
| #if !defined MYSTD_IOSTREAM_H
| #define MYSTD_IOSTREAM_H
| #include <iostream>
| using namespace std;
| #endif

You would direct the compiler to start searching for headers in the
directory you put the headers in, normally with a "-I" option like
'-Imystd'. Using headers like this should resolve most problems. A
few remaining problems would be caused by certain names which are
not supported by the standard like 'ios::nocreate' (this particular
flag can simply be dropped).

This should resolve the majority of problems. Actually, off-hand I
can't remember any other problems I had for projects where I made
the transistion. However, I'm quite familiar with the standard
IOStreams library and resolve most problems related to it without
much thinking. If you did as above and are still stuck with
problems you cannot resolve, I'm pretty sure somebody here can help
you out if you can post a small (but complete) fragment which causes
a problem when being compiled.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #3
S. Nurbe wrote:
probably this is a common problem but I couldn't find yet a proper
solution (and I hope there is one).
I think the only solution to this problem was discussed in this
forum several times. You might, however, not like the answer:
essentially, you have no alternative than changing the code to
use the standard headers.
Is it somehow possible to put them together to one framework and solve the iostream problem (also other header are effected, e.g. fstream)?
Yes: change all uses of the .h-headers to uses of the standard
headers. Since the standard headers define their names in namespace
'std' you also need to change your code to search the names therein.
The easiest approach for a transistion like this is to use a using
directive, that is, you would change

| #include <iostream.h>

to become

| #include <iostream>
| using namespace std;

Using namespace directives like above, especially in headers, is
frowned upon and should normally not be done. However, it is a
viable approach if you need to port pre-standard C++ code. The
uses should eventually be removed and new code should neither
introduce them nor assume they are used somewhere else.

An approach easing this transistion is to provide your own version
of the .h-headers which look essentially like this:

| // file: mystd/iostream.h
| #if !defined(MYSTD_IOSTREAM_H)
| #define MYSTD_IOSTREAM_H 1
| # include <iostream>
| using namespace std;
| #endif /* MYSTD_IOSTREAM */

You would then direct the compiler to search the directory where
you put the headers first, typically with an option looking like
this: '-Imystd' (without the delimiting quotes, of course).

The remaining problems should be simple to resolve. Essentially,
only a few unnecessary flags (like 'ios::nocreate') were defined
in the pre-standard headers. You might also encounter uses of
'opfx()', 'osfx()', 'ipfx()', or 'isfx()' which are unavailable.
These are replaced by uses of 'std::ostream::sentry' and
'std::istream::sentry' but actually this is quite unlikely
(unless you had an IOStream expert in your team...). I don't
remember any other problems from the transistion (but then, I'm
quite familiar with the IOStreams library and just fix the code
rather than thinking much about it).
If I just change the header in one framework I get lots of errors,
which are very difficult to fix (at least for me).


There shouldn't be any problems which are difficult to fix. If
you did as described above and you are still stuck with a problem
I'm sure you can get help in this forum: just post a short excerpt
which displays the problems (you might want to search the group
archives for the respective problem before that since I remember
helping people with resolving the transistion problems before).
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #4
Dietmar Kuehl wrote:
[a second reply to the original question...]

The beta of the google groups interface suc^Hffers from
substantial problems: it reported an error for my first reply
("Server error") and the article didn't show up for quite a
while. This lured me into writing a second reply... (which is,
however, a little bit more complete than the first one as I
remembered a particular but rare problem).
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #5
Hi,

it was less work to rewrite the code than I thought (curiously) but
now, when I add a library which previously worked I get a lot of linker
errors ~40, all from the same type) which I cannot solve:
one of them is this:
msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: bool __thiscall
std::ctype<char>::is(short,char)const " (?is@?$ctype@D@std@@QBE_NFD@Z)
already defined in Calibration.obj

When I ignore msvcprtd.lib I get approx 400 linker errors like the
following:

NumRecCpp.lib(brent.obj) : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: unsigned short __thiscall
std::basic_ios<unsigned short,struct std::char_traits<unsigned short>
::fill(void)const " (__imp_?fill@?$basic_ios@GU?$char_traits@G@std@@@s td@@QBEGXZ)

NumRecCpp.lib(mnbrak.obj) : error LNK2019: unresolved external symbol
"__declspec(dllimport) public: unsigned short __thiscall
std::basic_ios<unsigned short,struct std::char_traits<unsigned short>::fill(void)const "

(__imp_?fill@?$basic_ios@GU?$char_traits@G@std@@@s td@@QBEGXZ)
referenced in function
__ehhandler$??$?6GU?$char_traits@G@std@@V?$allocat or@G@1@@std@@YAAAV?$basic_ostream@GU?$char_traits@ G@std@@@0@AAV10@ABV?$basic_string@GU?$char_traits@ G@std@@V?$allocator@G@2@@0@@Z

BTW: it's from numerical recipies...

What can that be?
P.S. The 'ios::nocreate' flag can just be ignored?

Jul 22 '05 #6
OK, I fixed it - there was a problem with the compilation of one of the
libs...

Jul 22 '05 #7
re*******@yahoo.de wrote:

Let me guess... you're using MATLAB 6.5(.x).

I had the same issue.
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
89328
by: John Tiger | last post by:
Can anybody have idea about the difference between #include <iostream.h> and #include <iostream>. Is later one valid statement on any compiler. I tried compiling on MSVC second statement give...
13
3392
by: ncstate | last post by:
it seems when i try to compile this simple code I get an error message i believe is from g++ not finding the IOSTREAM header file. i found the header file in /usr/include/c++/3.2.2/ so that is why...
19
3821
by: ernst.stiegler | last post by:
Hello, I just want to read a whole line from a console input. What I don't understand is that I always have to press ENTER twice in order to see the line I've entered. Here's my code : ...
1
3832
by: Pradyot Dhulipala | last post by:
Hi, I am using ns2.26 with the Makefile using C++ compiler version c++ (GCC) 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk). When I use iostream.h in a simple program and compile with c++ everything works...
2
3960
by: humble04 | last post by:
Hi, I am compiling a collection of C++ code. Most of them are using the new format #include <iostream>. I think all of them because I failed at finding out which header file uses the old format ...
1
2925
by: Shane Ragone | last post by:
What happened to iostream.h in VS .NET? Are we now to code: #include <iostream> instead of: #include <iostream.h> All my past code that used iostream.h will no longer
1
4507
by: Bill Sun | last post by:
Hi, I just want to using a console application in the .net enviroment. Before the main(), I using the #include "iostream.h" but the .net tell me:...
1
1353
by: Ly Hoang Hai | last post by:
Hi all, I have just port my C++ 6.0 project into C++ project of Visual Studio.NET. However, .NET tell me that it can not find iostream.h. Some search on the internet tell me that I should change...
2
7141
by: NewToCPP | last post by:
I am having some trouble including "iostream" "fstream" to my code. I tried the following ways and base times it did not work. What is the problem? test.cc: ======= ..... #include...
0
7220
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.