I am trying to wrap an old library using STL so we don't have to change all the 50 applications to use STL. The old library used the IString class so here is what my test wrapper class looks like but the problem is that when I try to compile the applications with this class I get a bezillion errors. I am guessing it has got something to do with the old style C++ vs new. All the old apps use the extern'C' linkage for the header files and this new stuff is using #include <string> and 'using namespace std' so that is where the conflict lies. Here is my test class:
IString.hpp
----------------------
Code:
#include <string>
using namespace std;
class IString
{
private:
string buffer;
public:
IString (char* str);
IString (string str);
unsigned length( );
IString subString(unsigned startPos, unsigned length);
};
IString.cpp
--------------------------
Code:
#include <istring.hpp>
IString::IString(char* str)
{
buffer = str;
}
IString::IString(string str)
{
buffer = str;
}
IString IString::subString(unsigned startPos, unsigned length)
{
return IString(buffer.substr(startPos, length));
}
unsigned IString::length()
{
return buffer.length();
}
and this is the error I get when I comment out 'using namespace std':
/usr/vacpp/bin/xlC_r -c -qsource -qlistopt -qxref -qattr -I/usr/lpp/db2_07_01/include -I/usr/vacpp/include -I/usr/vac/include -I/h/IOCDir/IDate -I/h/IOCDir/ITime -I/h/IOCDir/IString brocDB2.C
"/h/IOCDir/IString/istring.hpp", line 24.24: 1540-0040 (S) The text "buffer" is unexpected. "string" may be undeclared or ambiguous.
"/h/IOCDir/IString/istring.hpp", line 21.7: 1540-0403 (S) "class IString" is already defined.
"/h/IOCDir/IString/istring.hpp", line 21.7: 1540-0403 (S) "class IString" is already defined.
"brocDB2.sqC", line 50.6: 1540-1600 (W) "main" should have a return type of type "int".
make: 1254-004 The error code from the last command is 1.
and when I leave it in there I get TONS of errors.
Can someone shed some light on this subject?
Thanks!