如何在#if中使用#define? [英] How to use #define inside of #if?
本文介绍了如何在#if中使用#define?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要定义一个预处理器指令,它抽象出一些条件。
我想检测平台文件I / O支持。
所以我想定义一个像FILE_IO这样的预处理器指令来检测这个平台是否支持。
我需要一个预处理器指令,因为我不能在不支持的平台上使用File api,所以我需要在编译时停止使用它们。
看看下面的脚本。
我怎样才能实现这个目标?
任何帮助都表示赞赏。
我尝试过:
I needed to define a preprocessor directive, that abstracts some conditions.
I want to detect platform File I/O support.
So i want to define a preprocessor directive like FILE_IO to detect does this platforms supports or not.
I needed a preprocessor directive because i can't use File api on unsupported platforms, so i need to stop using them at compile time.
Take a look the below script.
How can i achieve this?
Any help is appreciated.
What I have tried:
// It won't work
#define FILE_IO = !SAMSUNG_TV && !WEBGL
// OR
#if !SAMSUNG_TV && !WEBGL
// It get defined anyway
#define FILE_IO
#endif
推荐答案
#define SAMSUNG_TC
#define WEBGL
#if!SAMSUNG_TC&& !WEBGL
#define FILE_IO
FILE_IO =!SAMSUNG_TC&& !WEBGL;
#endif
#define SAMSUNG_TC
#define WEBGL
#if !SAMSUNG_TC && !WEBGL
#define FILE_IO
FILE_IO = !SAMSUNG_TC && !WEBGL;
#endif
这篇关于如何在#if中使用#define?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文