Search code examples
c++aixxlc

The text "<" is unexpected when compiling with Xlc_r IBM compiler


I have a problem with the compiling of code with the xlC_r compiler on AIX OS. I have attached my code below which is causing the problem. I have tried to compile the code on MS Windows with microsoft compiler and also compiled it under Linux with gcc and everything worked fine. The compiler error which I get is following:

"...../ABC.h", line 12.22: 1540-0063 (S) The text "<" is unexpected.

I have searched the internet and I found some resources (link and link), I do not know how to integrate the solution into my code. One possible solution would be to remove the shared_ptr and just have the pointer value, but I do not like to manage the deleting of pointer by myself. I would relly appreciate any help.

ABC.h

#ifndef ABC_H
#define ABC_H

#include <vector>
#include <memory>

template<class SR_TYPE, class SM_TYPE>
class ABC {
   private:    
      std::shared_ptr<SR_TYPE> mpRV;
      std::vector<SM_TYPE>     mMsgs;

   public:
      ABC(void);
      ABC(SR_TYPE* pReturnValue);
      virtual ~ABC(void);
};    // ABC
template<class SR_TYPE, class SM_TYPE>
ABC<SR_TYPE, SM_TYPE>::ABC(void) {
}
template<class SR_TYPE, class SM_TYPE>
ABC<SR_TYPE, SM_TYPE>::ABC(SR_TYPE* pReturnValue) {
   mpRV.reset(pReturnValue);
}
template<class SR_TYPE, class SM_TYPE>
ABC<SR_TYPE, SM_TYPE>::~ABC(void) {
}
#endif // ABC_H

ABC.cpp

#include "ABC.h"

class ABCExtended : public ABC<int, std::string> {
   ABCExtended() :
      ABC<int, std::string>()
   {}
   ABCExtended(int* pReturnValue) :
      ABC<int, std::string>(pReturnValue)
   {}
};

Thanks in advance.


Solution

  • shared_ptr is from the TR1 so it should be used from that namespace

    change std::shared_ptr mpRV; to std::tr1::shared_ptr mpRV;

    Compile with -D__IBMCPP_TR1__