- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我目前正在移植一些 Windows 代码并尝试使其可用于 Ubuntu。该项目最初是用 VC++ 编译的,没有任何问题。另外我应该指出,这只需要在 Ubuntu 中工作,但当然欢迎更多平台独立的想法。
大部分代码很容易移植,因为它主要是一个数值模拟项目,只有很少的操作系统特定部分。移植版本中没有使用 UNICODE,也不需要支持它。
我想知道当试图让这段代码用 GCC 编译时最佳实践是什么,特别是:
什么被认为是 __int64、_tmain 和 _TCHAR* 的最佳替代品?
谢谢!
最佳答案
对于 64 位:
#include <inttypes.h>
typedef int64_t __int64;
至于TCHAR问题。我实际上发现 TCHAR 相当有用,所以我有一个文件,其中包含我在其中使用的所有 _t 函数。
例如
#ifdef UNICODE
#define _tcslen wcslen
#define _tcscpy wcscpy
#define _tcscpy_s wcscpy_s
#define _tcsncpy wcsncpy
#define _tcsncpy_s wcsncpy_s
#define _tcscat wcscat
#define _tcscat_s wcscat_s
#define _tcsupr wcsupr
#define _tcsupr_s wcsupr_s
#define _tcslwr wcslwr
#define _tcslwr_s wcslwr_s
#define _stprintf_s swprintf_s
#define _stprintf swprintf
#define _tprintf wprintf
#define _vstprintf_s vswprintf_s
#define _vstprintf vswprintf
#define _tscanf wscanf
#define TCHAR wchar_t
#else
#define _tcslen strlen
#define _tcscpy strcpy
#define _tcscpy_s strcpy_s
#define _tcsncpy strncpy
#define _tcsncpy_s strncpy_s
#define _tcscat strcat
#define _tcscat_s strcat_s
#define _tcsupr strupr
#define _tcsupr_s strupr_s
#define _tcslwr strlwr
#define _tcslwr_s strlwr_s
#define _stprintf_s sprintf_s
#define _stprintf sprintf
#define _tprintf printf
#define _vstprintf_s vsprintf_s
#define _vstprintf vsprintf
#define _tscanf scanf
#define TCHAR char
#endif
至于 _s 功能基本上......我实现了它们。这需要大约一个小时的编码时间,但它使将项目移植到其他平台或编译器变得非常容易。
关于c++ - 移植 windows 代码,用什么代替 __int64 _tmain 和 _TCHAR*?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3108220/
我有一个 mfc 项目,它是由 Windows 服务生成的进程。由于某种原因,这个过程在它开始之前就死了。全局值已创建,但进程不会启动 _tmain。从 VC6 迁移到 VS2012 时出现了这个问题
在 Visual C++ 2008 Express 中,当我创建一个新的控制台项目时,我得到以下程序作为开始: //Explodey.cpp : Defines the entry point for
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: What is the difference between _tmain() and main() in
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a min
如果我使用以下 main() 方法运行我的 C++ 应用程序,一切正常: int main(int argc, char *argv[]) { cout << "There are " << a
我目前正在移植一些 Windows 代码并尝试使其可用于 Ubuntu。该项目最初是用 VC++ 编译的,没有任何问题。另外我应该指出,这只需要在 Ubuntu 中工作,但当然欢迎更多平台独立的想法。
#define UNICODE #define WINVER 0x502 #include #include #include int _tmain( int argc, TCHAR* argv
我是一名优秀的程序员,十分优秀!