GoogleTest 1.6 com erro de compilação do Cygwin 1.7: 'fileno' não foi declarado neste escopo
GoogleTest 1.6 com Cygwin 1.7: 'fileno' não foi declarado neste escopo
Mensagem de erro ao criar um teste simples na função Factorial () no Eclipse CDT:
Invoking: Cygwin C++ Compiler
g++ -std=c++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"
In file included from E:\source\gtest-1.6.0\include/gtest/internal/gtest-internal.h:40:0,
from E:\source\gtest-1.6.0\include/gtest/gtest.h:57,
from ../src/challenge.cpp:11:
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h:1589:51: error: 'fileno' was not declared in this scope
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h:1595:57: error: 'strdup' was not declared in this scope
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h:1627:71: error: 'fdopen' was not declared in this scope
Eclipse CDT 8.1 executando o gcc 4.7.3 no Cygwin 1.7.22
gTest 1.6 com sucesso, incluindo testes de demonstração, com o cmake 2.8.9 no Cygwin 1.7.22
Eu vinculei a biblioteca construída com o caminho completo, E: \ lib \ gtest-1.6.0 \ Cygwin \ libgtest.a
A seguinte opção de comando foi adicionada manualmente, obteve o mesmo erro sem ela.
-DGTEST_OS_CYGWIN=1
Parece que os erros não têm nada a ver com o meu código. Qualquer um usando o gTest com o Eclipse e o Cygwin?
Obrigado,
unsigned long Factorial(unsigned n) {
return n==0? 0 : n*Factorial(n-1);
}
// Tests factorial of 0.
TEST(FactorialTest, HandlesZeroInput) {
EXPECT_EQ(1, Factorial(0));
}
// Tests factorial of positive numbers.
TEST(FactorialTest, HandlesPositiveInput) {
EXPECT_EQ(1, Factorial(1));
EXPECT_EQ(2, Factorial(2));
EXPECT_EQ(6, Factorial(3));
EXPECT_EQ(40320, Factorial(8));
}