如何检测是否支持在Windows DWORD_PTR类型,使用的ifdef? [英] How to detect if the Windows DWORD_PTR type is supported, using an ifdef?

查看:74
本文介绍了如何检测是否支持在Windows DWORD_PTR类型,使用的ifdef?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有<一个href=\"http://stackoverflow.com/questions/1271748/dword-ptr-int-ptr-long-ptr-uint-ptr-ulong-ptr-when-how-and-why\">some新的整数类型的Windows API中来支持Win64的。他们并不总是支持;例如它们不在MSVC6 的present。

There are some new integer types in the Windows API to support Win64. They haven't always been supported; e.g. they aren't present in MSVC6.

我怎么能写#如果状况来检测,如果这些类型是由&LT支持; WINDOWS.H&GT;

How can I write an #if condition to detect if these types are supported by <windows.h>?

(我的code需要在许多不同的版本的Microsoft Visual C ++的,包括MSVC6编译,所以我需要提供我自己的这些类型的定义,与#如果在新的编译器禁用它们)。

(My code needs to compile under many different versions of Microsoft Visual C++, including MSVC6. So I need to provide my own definitions of these types, with an #if to disable them in newer compilers).

(对于搜索,类型的完整列表是:DWORD_PTR,INT_PTR,LONG_PTR,UINT_PTR,ULONG_PTR)

(For searchers, the full list of types is: DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR, ULONG_PTR)

推荐答案

MSC_VER 的范围为[1200内的值, 1300)的MSVC 6.所以,你可以使用#如果MSC_VER&GT; = 1200安培;&安培; MSC_VER&LT; 1300

The macro MSC_VER is a value that is within the range [1200, 1300) for MSVC 6. So you can use #if MSC_VER>=1200 && MSC_VER<1300.

编辑:安德斯说,这是不是真的那么有效超出了试验的是我的编译器MSVC 6。但是,您也可以使用:

As Anders said, this is not really that valid of a test beyond "is my compiler MSVC 6". However, you can also use:

#if defined(MAXULONG_PTR)

由于 DWORD_PTR 是值类型,它在为它定义的最大值 basetsd.h

Since DWORD_PTR is a value type, it has a maximum value defined for it in basetsd.h.

这篇关于如何检测是否支持在Windows DWORD_PTR类型,使用的ifdef?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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