migrate CString in MFVC onto Linux

N

Nick

Hi,

I am almost a C++ newbie, and trying to migrate a VC++.net code onto a
Linux machine. The code uses a lot of cstring. On Linux, I found an
include file called cstring, so I include it into the code. But the
compiler always says:
error: identifier "cstring" is undefined
So, is there any easy way to solve it? Should I define a cstring class
by myself? Apparently I cannot just use typedef char* csthing, since
all its methods used in the code get lost.

Thanks for your help.
 
J

Jarmo

Nick said:
Hi,

I am almost a C++ newbie, and trying to migrate a VC++.net code onto a
Linux machine. The code uses a lot of cstring. On Linux, I found an
include file called cstring, so I include it into the code. But the
compiler always says:
error: identifier "cstring" is undefined
So, is there any easy way to solve it? Should I define a cstring class
by myself? Apparently I cannot just use typedef char* csthing, since
all its methods used in the code get lost.

Thanks for your help.

You have access to the MFC source code so it may be worth porting the
CString class over to your Linux compiler. Alternatively replace all use of
CString with std::string though this would probably require lots of code
changes as the two classes are not compatible.
 
V

Victor Bazarov

Nick said:
I am almost a C++ newbie, and trying to migrate a VC++.net code onto a
Linux machine. The code uses a lot of cstring. On Linux, I found an
include file called cstring, so I include it into the code. But the
compiler always says:
error: identifier "cstring" is undefined

The header <cstring> has nothing to do with MFC's CString class.
So, is there any easy way to solve it?

You would have to define "easy".
Should I define a cstring class
by myself?

I would rather replace all references to CString with std::string
and fix those things that don't compile. That way you will get your
code to comply with the Standard on any platform with a recent C++
compiler.
Apparently I cannot just use typedef char* csthing, since
all its methods used in the code get lost.

Yes, apparently.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top