Sign in to follow this  
BTownTKD

working between g++ and MSVC++

Recommended Posts

I'm working with hash_maps in g++ using #include<ext/hash_map> and would like to work on my code in visual studio at home. The "hash_map"s in visual studio, however, are different (both in implementation AND include-file location) from g++'s. Is there an easy way to get VC++ 2005 to compile my code from g++?

Share this post


Link to post
Share on other sites
Rip out g++'s implementation, and copy it into your project. Being templated, it should all be in the headers. You might have to do some voodoo to get it to compile, but it might not be that difficult.

You could also download SGIs implementation, and convert your code to use it instead. I'll bet that'll require less work to get it to compile properly, should that prove problematic.

CM

Share this post


Link to post
Share on other sites
Quote:

#ifdef _WIN32
#include
#else
#include
#endif


The only problem here is that the IMPLEMENTATION differs between the two, not just the #include path (and I'd rather not have to do #ifdefs for every single line that involves a hash_map...).

I think I'll try downloading SGI's libraries... that IS what g++ uses, right?

Thanks again

Share this post


Link to post
Share on other sites
Quote:
Original post by BTownTKD
I think I'll try downloading SGI's libraries... that IS what g++ uses, right?

I have no idea, but it'll definately give you a common interface that will probably work for both systems.

CM

Share this post


Link to post
Share on other sites
Quote:
Original post by BTownTKD
I think I'll try downloading SGI's libraries... that IS what g++ uses, right?


No.

The GNU standard C++ library, aka libstdc++, imported parts of SGI's STL at one point but made a lot of modifications to (a) make it conform to the standard and (b) improve performance in many ways (one of the GNU contributors was the same guy who implemented the SGI version, and he later came up with better ideas).

Most of te SGI extensions, like rope and the hash tables, are still pretty much the same but not exactly identical. You may get lucky.

If you really want portability, use the tr1 unordered containers. They're available in modern versions of GCC and I believe they're also available in later MSVC versions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this