如何处理OS X Yosemite Core标头中的非gcc兼容代码 [英] How to cope with non-gcc compatible code in OS X Yosemite Core headers

查看:85
本文介绍了如何处理OS X Yosemite Core标头中的非gcc兼容代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我维护了一个混合的C和C ++命令行程序,该程序需要在Linux,Windows和OS X上运行。我最近升级到Yosemite,而我的OS X构建现在失败了。错误是:

I maintain a mixed C and C++ command line program that needs to run on Linux, Windows, and OS X. I recently upgraded to Yosemite and my OS X build is now failing. The error is:

/usr/include/dispatch/object.h:143:15: error: expected identifier or '(' before '^' token

其他人也遇到了此错误

失败的代码行是使用'^'的typedef这是一个为扩展包提供支持的非标准扩展

The line of code that fails is a typedef that uses '^' which is a non-standard extension providing support for closures.

潜在的问题似乎是某些Apple标准标头开始需要Clang特定的扩展名。不幸的是,我们的程序具有非常深的依赖关系集,其中一些依赖项无法在Clang下编译。通过MacPorts安装的GCC编译器,我现在有一个解决方法:将 object.h 标头中的行更改为与GCC兼容,但是,破坏了<$下的包含文件c $ c> / usr / include 在我看来听起来很麻烦。

The underlying problem seems to be that some Apple standard headers are starting to require Clang specific extensions. Unfortunately our program has a very deep set of dependencies, some of which won't compile under Clang. We've been using the GCC compilers installed via MacPorts. I have a workaround for now: changing the line in the object.h header to be GCC compatible. However, hacking up the include files under /usr/include sounds to me like asking for trouble.

任何OS X / Clang专家都可以提出更可持续的方法来解决此问题吗?

Can any OS X/Clang gurus suggest more sustainable ways of coping with this problem? Does this limit the future usefulness of GCC on OS X?

推荐答案

仅对未来的访问者而言,以下内容应可与大多数标头一起使用最新的GCC版本:

Just for future visitors, the following should get most headers working with a recent GCC version:

dispatch / object.h 更改

typedef void(^ dispatch_block_t)(void);

to

#ifdef __clang__
typedef void (^dispatch_block_t)(void);
#else
typedef void* dispatch_block_t;
#endif

Availability.h 更改

#elif已定义(__MAC_OS_X_VERSION_MIN_REQUIRED)

#elif已定义(__MAC_OS_X_VERSION_MIN_REQUIRED)&&已定义(__clang __)

这篇关于如何处理OS X Yosemite Core标头中的非gcc兼容代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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