在使用eclipse +cdt + gtest1.7写测试用例时,发现将编译选项增加-std=c++11时,出现如标题所示错误,搜索后结果如下:
Some functions go beyond the ANSI standard. These are disabled when you use std=c++11 (or std=c++0x).
Among them are fdopen, fileno and strdup. There are two possibilities to use them:
- Use the GNU dialect (std=gnu++11).
- If you want to compile without dialect and make a local exception, you can include stdio.h with the STRICT_ANSI undefined. (see: Error “‘fdopen’ was not declared” found with g++ 4 that compiled with g++3)
摘自stackoverview
用方法一可以解决这个编译错误。