Link to home
Start Free TrialLog in
Avatar of Abhi072299
Abhi072299Flag for India

asked on

Can we simultaneously use Old C++ Headers and New C++ Headers?

Hi,
 
   We are working on an application written in C++. We are using MS Visual Studio 6.0 as IDE. The requirement is to use STL and Boost C++ classes in our code.  To fullfil this requirement we decided to create a DLL having wrapper classes on Bosst and STL and then to implicit link the DLL with the application. We have used Visual Studio 2008 Express edition to build the DLL.

Can you please help me with the following:
1) Do you see any issues with this approach? Will it work? Please let me know in the context of the following excepts from Web:

 I have gone through the MS KB article (http://support.microsoft.com/kb/q154419/) where they have stated that

*************************************************************************************
Remember, you cannot mix calls to the old iostream and the new Standard C++ library. Existing libraries (static or dynamic link) that use old iostream functions will have to be modified to use Standard C++ library iostream functions.
*************************************************************************************

On other site I found:
*************************************************************************************
Note - Mixing old and new forms of iostreams--including the standard input and output streams cin, cout, and cerr--in the same program can cause severe problems and is not recommended.
*************************************************************************************
2) Will the DLL built on MS VS 2008 would work fine with the application built on using VC++ 6.0 compiler?

3) My another option would be to change my application to use new C++ headers instead of old ones. Here when I tried this I got the following warnings.

*******************************************************************************************
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(39) : error C2220: warning treated as error - no object file generated
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(39) : warning C4100: '_P' : unreferenced formal parameter
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(41) : warning C4100: '_P' : unreferenced formal parameter
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(242) : warning C4511: 'codecvt_base' : copy constructor could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(223) : see declaration of 'codecvt_base'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(242) : warning C4512: 'codecvt_base' : assignment operator could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(223) : see declaration of 'codecvt_base'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(296) : warning C4663: C++ language change: to explicitly specialize class template 'codecvt' use the following syntax:
        template<> class codecvt<unsigned short,char,int> ...
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(398) : warning C4511: 'codecvt<unsigned short,char,int>' : copy constructor could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(296) : see declaration of 'codecvt<unsigned short,char,int>'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(398) : warning C4512: 'codecvt<unsigned short,char,int>' : assignment operator could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(296) : see declaration of 'codecvt<unsigned short,char,int>'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(387) : warning C4018: '<' : signed/unsigned mismatch
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(420) : warning C4511: 'ctype_base' : copy constructor could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(410) : see declaration of 'ctype_base'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(420) : warning C4512: 'ctype_base' : assignment operator could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(410) : see declaration of 'ctype_base'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(519) : warning C4663: C++ language change: to explicitly specialize class template 'ctype' use the following syntax:
        template<> class ctype<char> ...
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(611) : warning C4511: 'ctype<char>' : copy constructor could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(519) : see declaration of 'ctype<char>'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(611) : warning C4512: 'ctype<char>' : assignment operator could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(519) : see declaration of 'ctype<char>'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(552) : warning C4100: '_D' : unreferenced formal parameter
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(554) : warning C4100: '_D' : unreferenced formal parameter
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ostream(50) : warning C4512: 'sentry' : assignment operator could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ostream(38) : see declaration of 'sentry'
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ostream(373) : see reference to class template instantiation 'std::basic_ostream<char,struct std::char_traits<char> >' being compiled
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ostream(50) : warning C4512: 'sentry' : assignment operator could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ostream(38) : see declaration of 'sentry'
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ostream(379) : see reference to class template instantiation 'std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >' being compiled
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(513) : warning C4511: 'ctype<unsigned short>' : copy constructor could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\istream(573) : see reference to class template instantiation 'std::ctype<unsigned short>' being compiled
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(513) : warning C4512: 'ctype<unsigned short>' : assignment operator could not be generated
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\istream(573) : see reference to class template instantiation 'std::ctype<unsigned short>' being compiled
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\streambuf(181) : warning C4100: '_Loc' : unreferenced formal parameter
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\streambuf(182) : while compiling class-template member function 'void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::imbue(const class std::locale &)'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\streambuf(181) : warning C4100: '_Loc' : unreferenced formal parameter
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\streambuf(182) : while compiling class-template member function 'void __thiscall std::basic_streambuf<unsigned short,struct std::char_traits<unsigned short> >::imbue(const class std::locale &)'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(600) : warning C4245: 'initializing' : conversion from 'const int' to 'const unsigned int', signed/unsigned mismatch
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(59) : while compiling class-template static data member 'const unsigned int std::basic_string<char,std::char_traits<char>,std::allocator<char> >::npos'
*******************************************************************************************

Is there any other way to do this?

Please help me out.

Regards
Abhishek
 
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Abhi072299

ASKER

Hi evilrix,

   Thanks for the response. I am very sorry for the delayed response.
   
    By new and old I headers I mean exactly the same i.e. <iostream.h> vs. <iostream>.  I understand that migration to new compiler would be benificial but due to our large codebase and some constraints we can not do it as this moment.  I need to complete the things with VS 6.0 only.

Regards
Abhishek



   
 
>> Thanks for the response.
Very welcome

>> I am very sorry for the delayed response.
No worries, there is no rush :)

>> I mean exactly the same i.e. <iostream.h> vs. <iostream>
Then what I said above stands... it's unsafe to mix them up like this.
OK. Can you please let me know what can be the prospetive issues? If you can refer to some book or document then that would be great.
Hi Abhi. What Evilrix has told are right. You can't mix up them. If you are aware of using VS2008,2005 then very easily you can solve your compiler errors,warnings. Because once you load the *.dsw files to the VS2005,2008 it will ask for conversion. After converting them you just compile the whole project. Obviously you will get some errors. If you make *.dll projects then its from the very beigining. You should follow the correct procedure to make a DLL. Also there are some project settings, which are to set properly while making a DLL. I mean project property settings.

Following is a tutorial to make a DLL and how to test them.

http://www.functionx.com/visualc/libraries/win32dll.htm
Hi Pramod,

  I understand I can't mix them. But my point is if I am making a DLL in VS 2008 and use it along with my VC++ 6.0 application then what would be the issue. I am using OCI in my application. My application don't know whether it is built on VS 6.0 or VS 2008 and may be they have used STL also inside it. Same is the case with Microsoft System DLL's. My application might be using them in the same way.

There are some depencies on 3rd Party Libraries due to which I can't migrate to VS 2005/2008.

Regards
Abhishek
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What I know and used is that if you build a DLL in VS2008, you can use it in VS6.0 also.
No problems with project settings in VS2008. Because you are going to export some methods,Objects from the DLL. but you need know what type of DLL you are making i.e. win32 dll or extension dll.
>> What I know and used is that if you build a DLL in VS2008, you can use it in VS6.0 also.
And that is fine if you are using intrinsic types that have the same memory representation, but that isn't what we're talking about here.
>>>> 2) Will the DLL built on MS VS 2008 would work fine with the application built on using VC++ 6.0 compiler?
I don't think it will work fine beside the functions to call were trivial.

But especially I don't see any advantage for to using VC6 for the application and VC9 for the dll. There already is a STL in VC6 (not really compatible to C++ standard but good enough if the old iostream classes are the alternative)and probably there is also a Boost library compatible to VC6.

If you need a better compiler or better libraries, then convert both the app and the dll to VC9. The potential issues when doing so are well-known and could be all solved in a reasonable time.

>>>> xlocale(242) : warning C4511: 'codecvt_base' : copy constructor could not be

Those errors look as your VC6 tries to use the include files from VC9 what couldn't work.

If using VC6 and VC9 on same computer you definitively need to separate the folders for include files, library files and executable files which are defined below Tools - Options. Also the PATH environment variable should not contain paths of both VC branches so that an executable built in VC6 doesn't use dlls from VC9 and vice versa.

I made good experiences by defining a new drive X via SUBST command which either points to VC6 root (C:\Program Files\Microsoft Visual Studio) or to VC9 root (C:\Program Files\Microsoft Visual Studio .NET 2008 Express Edition ... or similar). Then, you can add paths of both environments using the X: but only one is valid at a time depending on your current subst definition.


The question...

"Can we simultaneously use Old C++ Headers and New C++ Headers?"

Was answered here: http:#25691239
The question...

     "Can we simultaneously use Old C++ Headers and New C++ Headers?"

was only the header of the question.

The real questions were

>>>> (1) Do you see any issues with this approach? Will it work? Please let me know in the context of the following excepts from Web:

>>>> 2) Will the DLL built on MS VS 2008 would work fine with the application built on using VC++ 6.0 compiler?

>>>> 3) My another option would be to change my application to use new C++ headers instead of old ones. Here when I tried this I got the following warnings.

where IMO none of these was answered by http:#25691239

I tried to answer (2) in #25718429 but as I got no feedback it is ok for me if you delete the question with no refund.


Hi,

  Sorry for not responding to any mail. That is a fault from my end. I am very thankful to experts for spending time on my question.

I have opted for Option #3 as I had mentioned in my original question.

I understand that VC++ 6.0 is an age old IDE but as we have a very large project in hand, so we can't move to newer version of Visual C++ right away. STL that came with VC++ 6.0 worked fine in my case except some challenges that I had faced using std::string class. These issues were related to reference counting in a multithreaded enviornment.

I had tried option #2 also where I had build a DLL using VC++ 2008 and used it in VC++ 6.0. This will not work as there is a implementation difference in STL in these two compilers. As we have already written as class wrapper on VC++ 6.0 STL and it was working fine. But as soon as we moved it to VC++ 2008, the things were erratic.

I request you to not to delete the question as this discussion may be helpful who are facing the same problem.

Regards
Abhishek

>>>> Force closed per Asker comment.
As already told the answer http:#25691239 answered none of the three questions asked.

For example question #3 asked for help on compiler errors and warnings which not even were mentioned in the accepted answer.



Hi,

  With due respect to moderator, the answer choosen as Accepted Solution is not correct. What the expert has suggested out there I had written the same in my question #1. The expert has provided the partial answer to my question in "10/30/09 02:13 PM, ID: 25701015" where he had mentioned what is the actual issue.

I have opted for #3 which nobody has mentioned in the conversations.

In my view "10/30/09 02:13 PM, ID: 25701015" is the assisted solution as it talked about the inconsistencies in general.

Regards
Abhishek

Regards
Abhishek
Hi,

  With due respect to moderator,  25691239 should not be considered as the expected solution.

Regards
Abhishek
Firstly, I thank you for your feedback ;-)

>>>> I have opted for #3 which nobody has mentioned in the conversations.

You may look at my comment http:#25718429, second part. I think most compiler errors and warnings were due to wrong include folders the VC6 was accessing. You need to separate VC6 and VC9 environment thorougly, especially in the VC settings you can find in menu Tools - Options - Directories ... Here all paths must be unique for the VC6 so that no VC9 header files were included.
Thanks for the response. With due respect I want to clarify that the warnings are coming on those setups also where I have only Visual C++ 6.0.

I have not mixed these two enviornments together.

Regards
Abhishek
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks itsmeandnobodyelse. We have already used pragma directive to remove most of the warnings.

Regards
Abhishek
Abhishek,

Regarding your objection to closure of this question. Please do open a request for attention (using the link at the top right) and it will prompt a moderator to request a review from an independent Zone Advisor. I am happy for the question to be closed differently if another ZA agrees with you.

Thanks.

-Rx.
Thanks evilrix. I will do that. You have provided the answer in 25701015 for my point #2. So in case of force closure also this should be considered as Accepted Solution as it is giving the insight and most of the people who will read this post will benifit from it.

Regards
Abhishek
Abhishek,

If Alex has no objections I am happy to reopen this question for you to close yourself. Otherwise, if you open the RA a mod will handle this for you.

Thanks.

-Rx.
Hi evilrix,

  I am not able to find the link that you have mentioned in last mail. Please let me know exactly where it is.

Regards
Abhishek
>>  I am not able to find the link that you have mentioned in last mail. Please let me know exactly where it is.
It's at the very top right of this page just below your question text above the "View Solution" button.

Like I said though, if Alex is in agreement I can reopen this for you without the need for a moderator. Wait to see what Alex thinks first... unless you're prefer to just request attention. I am happy however you wish to proceed. The important thing is we get the right answer selected that actually assisted you.
I would be happy if the thread was closed by the Author.

Regards, Alex
Thanks Evilrix and Alex. My aim of raising the objection was only to provide the correct solution to the people who will look at this thread in future. You must agree with me that making the compatibility between new and old releases of complires is not easy.

In my view "10/30/09 02:13 PM, ID: 25701015" and 10/30/09 02:13 PM, ID: 25701015 given by Evilrix and "12/10/09 03:32 PM, ID: 26016463" given by Alex as the solution to the problem.

I will also suggest the readers of the post to read "12/03/09 10:22 AM, ID: 25959318" for the solution that I had opted for my problem.

Evilrix and Alex, I would need your input for the same. If you both will agree then I will close this thread by saying these as solutions. If you think otherwise then please let me know.

Regards
Abhishek
>> My aim of raising the objection was only to provide the correct solution to the people who will look at this thread in future.
Understood... that is all that is important.

>> If you both will agree then I will close this thread by saying these as solutions.
I am happy for you to close this as you suggest if they are the solutions that assisted you.

Thanks Abhishek & Alex.
Perfect ;-)  Have a nice time.