GoogleTest 1.6 with Cygwin 1.7 compile error: 'fileno' was not declared in this scope

南笙酒味 提交于 2019-11-29 03:24:41

Setting the C++ standard to -std=gnu++0x rather than -std=c++0x, worked for me. You can try the statement:

g++ -std=gnu++0x -DGTEST_OS_CYGWIN=1 -I"E:\source\gtest-1.6.0\include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/challenge.d" -MT"src/challenge.d" -o "src/challenge.o" "../src/challenge.cpp"

Setting symbol (-DGTEST_OS_CYGWIN=1) has got nothing to do with this error.

ManuelAtWork

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:

I have tested both on Suse Linux Enterprise 11, MinGW and Cygwin.


Addition: Another (possibly better) way to access non-ANSI symbols would be to add

#define _POSIX_C_SOURCE 200809L

before the first #include in your file. This will give you access to most of the non-standard routines.

Some functions (e.g. realpath(...)) require

#define _BSD_SOURCE

to be inserted on top of your file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!