在Linux中与Win32数据类型等效 [英] Win32 data types equivalant in Linux

查看:69
本文介绍了在Linux中与Win32数据类型等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试转换在程序中广泛使用DWORD,CString和BYTE的C ++库,现在我将代码从C ++ Win32库转换为linux程序. 另外,我正在使用openSUSE 12.3和Anjuta IDE来执行此操作,请帮助我应使用哪些类型而不是所提到的类型? 我想我应该对DWORD使用unsigned int,对CString和unsigned char使用字符串,而不是BYTE,对吗?

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 . Also I am using openSUSE 12.3 and Anjuta IDE to do this , please help me which types I should use instead of mentioned types ? I think I should use unsigned int for DWORD and string for CString and unsigned char instead of BYTE is it right ?

推荐答案

CString不会直接转换为std::string,但大致等效.

CString will not convert directly to std::string, but it is a rough equivalent.

BYTE确实是unsigned char,而DWORDunsigned int. WORDunsigned short.

BYTE is indeed unsigned char and DWORD is unsigned int. WORD is unsigned short.

您绝对应该使用typedef actual_type WINDOWS_NAME;来修复代码,而不要遍历替换类型.我将添加一个称为"wintypes.h"之类的新头文件,并在所有使用"windows.h"的地方包括该文件.

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.

编辑评论: 使用CString,实际上取决于它的使用方式(以及代码是否使用MS称为"Unicode"或"ASCII"字符串的字符).我很想创建一个类CString,然后在其中使用std::string.大多数操作可能只需要简单地调用等效的std::string函数即可完成,但是某些功能可能需要更多的编程-再次,这确实取决于实际使用的是CString的哪些成员函数.

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.

对于LP<type>,这只是指向<type>的指针,因此typedef BYTE* LPBYTE;typedef DWORD* LPDWORD;将执行此操作.

For LP<type>, that is just a pointer to the <type>, so typedef BYTE* LPBYTE; and typedef DWORD* LPDWORD; will do that.

这篇关于在Linux中与Win32数据类型等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆