Menu

CppUnit on HPUX with aCC

Help
2003-06-12
2004-03-16
  • Michael Hart

    Michael Hart - 2003-06-12

    I'm trying to use CppUnit 1.8 on HPUX 11.0, with aCC version 3.30. CppUnit requires the new STL libraries, version 2.0, which requires the environment variable CXXFLAGS="-AA" to be set. No problem... until you try to link in other libraries that have been compiled with previous (incompatible) STL libraries.

    These incompatibility issues are well known, (see compiler reference at http://docs.hp.com/hpux/onlinedocs/dev/aCC/a_03_30/options.htm#optioncap-AA\) for more info) but very frustrating. Basically you can't mix libraries or object modules that use different versions of STL.

    My code needs to link to external libraries that use the previous versions of STL, I can't figure out how to use CppUnit with these previous versions. The offending code is in include/cppunit/Portability.h, where neither CPPUNIT_HAVE_SSTREAM and  CPPUNIT_HAVE_CLASS_STRSTREAM are defined, and it refuses to compile.

    Has anyone else run into this? Any ideas how to get around this?

    thanks
    mike

     
    • Clyde Gerber

      Clyde Gerber - 2004-03-16

      It's been some time since this message was posted, so hopefully the poster found a way around this issue.  I just had to deal with it myself, so I'm posting what I had to do.

      Outline:

      1.  Modify include/cppunit/Portability.h to detect
          the HP situation and conditionally define some
          global functions and classes as part or the std
          namespace.

      2.  Modify the implementation of OStringStream in
          include/cppunit/Portability.h to include
          strstream.h rather than strstream and remove
          the call to ostrstream::freeze.

      3.  Modify src/cppunit/TestFactoryRegistry.cpp and
          src/cppunit/XmlOutputter.cpp so that the
          std::map::insert function is found.

      4.  Modify src/cppunit/Makefile.in so that
          src/cppunit/SourceLine.h is built first.

      5.  Modify the following files to include iostream.h
          rather than iostream:

          include/cppunit/CompilerOutputter.h
          include/cppunit/TextOutputter.h
          include/cppunit/TextTestResult.h
          include/cppunit/XmlOutputter.h   
          src/cppunit/TestRunner.cpp
          src/cppunit/TextTestProgressListner.cpp

      Details:

      1.  After line 3 of include/cppunit/Portability.h, add:

      /* Added to allow compilation with -AP flag on
          HPUX */
         #if (__hpux)
         #ifndef _HP_NAMESPACE_STD
         #define _HP_AP_OPTION
         #include <string>
         #include <deque>
         #include <vector>
         #include <typeinfo>
         #include <map>
         #include <set>
         #include <utility>
         namespace std 
         {
             using ::string;
             using ::exception;
             using ::deque;
             using ::ostream;
             using ::vector;
             using ::endl;
             using ::find;
             using ::type_info;
             using ::map;
             using ::set;
             using ::make_pair;
             using ::pair;
             using ::remove;
             using ::cout;
             using ::cin;
             using ::cerr;
         }
         #endif
         #endif

      2.  After line 58 of include/cppunit/Portability.h, add:

         #ifdef _HP_AP_OPTION
         #   include <strstream.h>
             namespace CppUnit {
               class OStringStream : public ostrstream 
               {
               public:
                   std::string str()
                   {
                     (*this) << '\0';
                     std::string msg(ostrstream::str());
                     return msg;
                   }
               };
             }
         #else

         and after line 83 add the additional #endif.

      3. Replace line 72 of src/cppunit/TestFactoryRegistry.cpp with:

         #ifdef _HP_AP_OPTION
             Registries::value_type foo(name, factory);
             m_registries.insert( foo );
         #else
           m_registries.insert( std::make_pair( name, factory ) );
         #endif

         and replace line 219 of src/cppunit/XmlOutputter.cpp with:

         #ifdef _HP_AP_OPTION
             FailedTests::value_type foo(failure->failedTest(), failure);
             failedTests.insert( foo );
         #else
           failedTests.insert( std::make_pair(failure->failedTest(), failure ) );
         #endif

      4.  In src/cppunit/Makefile.in, move line 112 so that it follows line 106.

      5.  Add an #ifdef using the new _HP_AP_OPTION in Portability.h to
          conditionally include iostream.h rather than iostream.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.