#ifdef WIN32 #elif WIN64 #endif [英] #ifdef WIN32 #elif WIN64 #endif

查看:95
本文介绍了#ifdef WIN32 #elif WIN64 #endif的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些示例代码

#ifdef WIN32
   ...
#elif WIN64
   ...
#endif

#ifdef 块,使用 #elif 来表示 #elif已定义实际上合法吗?

In an #ifdef block, is it actually legal to use #elif to mean #elif defined?

推荐答案

不,不应该。并不是说有些晦涩的C编译器不会接受它,但是它不是C标准的一部分。

No, it shouldn't be. That's not to say that some obscure C compiler wouldn't accept it as such, but it isn't part of the C standard.

通常,对于像这样的事情,您将使用 #elifdef FOO (我在生产代码中从未见过)或 #elif define(FOO)(就像您提到的那样)。

Normally, for something like this you would use either #elifdef FOO (which I've never actually seen in production code) or #elif defined(FOO) (like you mentioned).

此代码似乎在以一种奇怪的方式工作;而是先检查是否定义了 WIN32 ,然后检查 WIN64 是否为非零。

This code appears to be working in a odd way; it's rather first checking if WIN32 is defined, then checking if WIN64 is nonzero.

这篇关于#ifdef WIN32 #elif WIN64 #endif的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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