PHOTOOG Photography writings by Olivier Giroux


Crossing Platforms on a Good Day

Sometimes things are just easy. Too easy maybe. Like in this one case here where we wanted to use STL-compatible hash maps in our cross-platform code.

We had conversations going in all directions there for a while (less-known boost utilities, in-house alternatives, wrappers, platform-specific alternatives) but in the end simplicity washed over us.

Check this out (yes, I Microsoft-colored this for you, it's soothing to me)(but Blogger pissed me off badly in the process):

#if ((defined(__GNUC__) defined(__ICC)) && !defined(USE_STLPORT))
  #include <ext/hash_map>
  #include <ext/hash_set>
  namespace stdext {
    using __gnu_cxx::hash_map;
    using __gnu_cxx::hash_set;
  #include <hash_map>
  #include <hash_set>
  #if (!defined(_MSC_VER) || (_MSC_VER < 1300))
    namespace stdext {
      using std::hash_map;
      using std::hash_set;

With this, we can access similar-enough hash_map implementations on all the compilers we care about. In all cases it'll be called stdext::hash_map. Easy this one.

Filed under: Uncategorized Leave a comment
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.