如何在 VC++ 中使用 _W64 和 __w64? [英] How do I use _W64 and __w64 in VC++?

查看:31
本文介绍了如何在 VC++ 中使用 _W64 和 __w64?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual 中有诸如 __w64 之类的东西C++ 9.我在尝试将我的本机 C++ DLL 移植到 64 位时遇到了它.特别是在 crtdefs.h 中有这个不错的片段:

There's such thing as __w64 in Visual C++ 9. I came across it while trying to port my native C++ DLL to 64 bit. In particular in crtdefs.h there's this nice snippet:

#if !defined(_W64)
#if !defined(__midl) && (defined(_X86_) || defined (_M_IX86)) && _MSC_VER >= 1300
#define _W64 __w64
#else
#define _W64
#endif
#endif

如果我猜对了,这意味着对于 64 位 _W64 被定义为空字符串并且没有任何效果,但是对于 32 位它被定义为 __w64.

which if I get it right implies that for 64 bit _W64 is defined as an empty string and has no effect, but for 32 bit it is defined as __w64.

我尝试将 _W64 定义为一个空字符串,然后将 __w64 定义为一个空字符串,并且至少这两次项目都可以在 64 位配置中正常编译.

I tried defining _W64 to be an empty string and __w64 in turn and at least both time the project compiles fine in 64-bit configuration.

也就是说 _W64__w64 看起来都没用.我打算如何使用它们以及我应该如何在 64 位项目中定义 _W64?

That said both _W64 and __w64 look useless. How am I intended to use them and how should I define _W64 in 64-bit projects?

推荐答案

答案是,你没有.这是供 32 位编译器使用的编译器功能.最初的想法是,微软想让程序员为即将到来的 32->64 位过渡做好准备.因此,32 位编译器获得了将某些 typedef 标记为 __w64 的能力.然后,Microsoft 使用这种能力来标记在 Win64 中会发生变化的 typedef.

The answer is, you don't. It's a compiler feature for use by the 32 bits compiler. The original idea was that Microsoft wanted to prepare programmers for the upcoming 32->64 bits transition. Therefore, the 32 bits compiler gained the ability to label certain typedefs as __w64. Microsoft then used that ability to label typedefs that would change in Win64.

这篇关于如何在 VC++ 中使用 _W64 和 __w64?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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