I am trying to convert a C++ library which is using widely DWORD, CString and BYTE in the program, and now I am converting the code from C++ Win32 library to linux program . Als
CString
will not convert directly to std::string
, but it is a rough equivalent.
BYTE
is indeed unsigned char
and DWORD
is unsigned int
. WORD
is unsigned short
.
You should definitely use typedef actual_type WINDOWS_NAME;
to fix the code up, don't go through everywhere to replace the types. I would add a new headerfile that is called something like "wintypes.h", and include that everywhere the "windows.h" is used.
Edit for comment:
With CString
, it really depends on how it is used (and whether the code is using what MS calls "Unicode" or "ASCII" strings). I would be tempted to create a class CString
and then use std::string
inside that. Most of it can probably be done by simply calling the equivalent std::string
function, but some functions may need a bit more programming - again, it does depend on what member functions of CString
are actually being used.
For LP
, that is just a pointer to the
, so typedef BYTE* LPBYTE;
and typedef DWORD* LPDWORD;
will do that.