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