学无先后,达者为师

网站首页 编程语言 正文

C/C++--跨平台--预定义宏 WIN32、_WIN32、_WIN64

作者:LtMamba 更新时间: 2023-10-14 编程语言

参考链接

1.windows环境预定义宏 WIN32、_WIN32、_WIN64

1.1 basic

  • WIN32
    只要包含了 Windows.h,那么 WIN32 常量是肯定定义了的,所以不能用于判断平台环境

  • _WIN32
    32位和64位程序都有,且总是定义的.

  • _WIN64
    只有64位程序才有,故此宏用来判断环境是 ×86 还是 ×64.

1.2 common code

1.2.1 判断是不是 windows 平台

#if _WIN32 || WIN32  //windows平台
...
#else 
...
#endif

1.2.2 判断是 64 位环境还是 32 位

#ifdef _WIN64
 
#ifdef _DEBUG
#pragma comment(lib, "*x64d.lib")
 
#else
#pragma comment(lib, "*x64r.lib")
#endif
 
#else
 
#ifdef _DEBUG
#pragma comment(lib, "*x86d.lib")
#else
#pragma comment(lib, "*x86r.lib")
#endif
 
#endif

原文链接:https://blog.csdn.net/qq_37233070/article/details/133693177

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新