内容简介:我们在实际编写代码的时候,经常需要判断当前编译环境是否存在我们需要的头文件,如果不存在,则使用其他头文件代替。以前这个操作都是通过外部的最近的
我们在实际编写代码的时候,经常需要判断当前编译环境是否存在我们需要的头文件,如果不存在,则使用其他头文件代替。
以前这个操作都是通过外部的 configure
文件生成 Makefile
的时候指定。
最近的 GCC
已经增加了 __has_include
这个内置函数判断头文件是否存在。
这个功能最早是 Clang
实现的,现在 GCC
终于补上了这个功能。
例子如下:
#ifdef __has_include # if __has_include(<optional>) # include <optional> # define have_optional 1 # elif __has_include(<experimental/optional>) # include <experimental/optional> # define have_optional 1 # define experimental_optional # else # define have_optional 0 # endif #endif
Code Composer Studio 8.2.0.00007
, GCC 5
支持这个内置函数。
参考链接
以上所述就是小编给大家介绍的《GCC支持在代码中对头文件是否存在的判断(__has_include)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Data-intensive Text Processing With Mapreduce
Jimmy Lin、Chris Dyer / Morgan and Claypool Publishers / 2010-4-30 / USD 40.00
Our world is being revolutionized by data-driven methods: access to large amounts of data has generated new insights and opened exciting new opportunities in commerce, science, and computing applicati......一起来看看 《Data-intensive Text Processing With Mapreduce》 这本书的介绍吧!