Chinaunix首页 | 论坛 | 博客
  • 博客访问: 54152
  • 博文数量: 15
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 107
  • 用 户 组: 普通用户
  • 注册时间: 2013-07-24 18:59
文章分类
文章存档

2015年(5)

2014年(1)

2013年(9)

我的朋友

分类: C/C++

2015-09-08 00:18:53

今天尝试在mac 上使用g++5,通过brew 可以轻松安装,但是在编译一个简单的程序时报错:

In file included from /usr/include/wchar.h:72:0,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/cwchar:44,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/bits/postypes.h:40,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/iosfwd:40,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/ios:38,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/ostream:38,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/iostream:39,

                 from easyTest.cpp:1:

/usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/Availability.h:179:44: error: missing binary operator before token "("

 #if defined(__has_feature) && __has_feature(attribute_availability_with_message)

                                            ^

In file included from /usr/include/wchar.h:72:0,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/cwchar:44,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/bits/postypes.h:40,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/iosfwd:40,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/ios:38,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/ostream:38,

                 from /usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/iostream:39,

                 from easyTest.cpp:1:

/usr/local/Cellar/gcc5/5.2.0/include/c++/5.2.0/Availability.h:189:44: error: missing binary operator before token "("

 #if defined(__has_feature) && __has_feature(attribute_availability_app_extension)

                                            ^

make: *** [easyTest] Error 1


应该是gcc安装有问题,尝试从源码安装 ,但是每次编译不过,
查找过程中有帮助的帖子主要有:
/> />
通过原理来看,需要在gcc自己使用的头文件中将 __has_feature 定义,但是又不能影响系统头文件,目前简单的解决方式是:
将 availability.h 拷贝套gcc5的安装目录一份,在gcc5 进行编译的时候会优先查找这个目录下的头文件,也符合修改编译源码时候 fixincludes.def的目标。

5.2.0 git:(master diff Availability.h /usr/include/Availability.h 

173,177d172

< /****

< #ifndef __has_feature

< #define __has_feature(x) 0

< #endif

< *****/



阅读(2942) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

liweimin902015-09-09 09:38:11

后来发现 mac 自带的clang 已经支持c++11 和c++ 14 了,用gcc -v 看到的 4.2.1 和gun gcc 4.2.1 是两码事。。。