2016-07-18 378 views
16

Spero che tu possa aiutarmi. Ho scritto un piccolo progetto usando CxxTest sulla mia macchina principale. Tutto funziona alla grande su questa macchina, nessun problema. Tuttavia, ho provato a impostare questo progetto sul mio nuovo portatile e non riesco a farlo funzionare! Ho il sospetto che qualcosa sia incasinato con la mia installazione MinGW piuttosto che CxxTest, ma è davvero difficile da sapere - e gli errori provengono dai file CxxTest. Questa è la struttura delle cartelle del progetto:MinGW/CxxTest errori bizzarri

lib/ 
    cxxtest-4.3/ 
src/ 
    TestUtils.h 
    test.cpp 
test/ 
    MyTestSuite.h 
    libstdc++-6.dll 

Sulla riga di comando corro:

cd test 
..\lib\cxxtest-4.3\bin\cxxtestgen --error-printer -o runner.cpp MyTestSuite.h 

Questo genera runner.cpp. Ora corro:

g++ -o runner.exe runner.cpp -I "../lib/cxxtest-4.3" -std=c++11 

Questo di solito funziona bene, emettendo runner.exe ed eseguendo i miei test di unità. Sul mio portatile ho solo migliaia di errori. Ecco uno sguardo al solo le prime:

In file included from c:\mingw\include\wchar.h:208:0, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\cwchar:44, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\bits\postypes.h:40, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\iosfwd:40, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\ios:38, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\istream:38, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\sstream:38, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\complex:45, 
       from ../lib/cxxtest-4.3/cxxtest/StdHeaders.h:24, 
       from ../lib/cxxtest-4.3/cxxtest/StdValueTraits.h:22, 
       from ../lib/cxxtest-4.3/cxxtest/ValueTraits.h:400, 
       from ../lib/cxxtest-4.3/cxxtest/TestSuite.h:24, 
       from ../lib/cxxtest-4.3/cxxtest/RealDescriptions.h:20, 
       from ../lib/cxxtest-4.3/cxxtest/TestRunner.h:22, 
       from runner.cpp:11: 
c:\mingw\include\sys/stat.h:173:14: error: '_dev_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_ino_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_mode_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_dev_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_off_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: 'time_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: 'time_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: 'time_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_dev_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_ino_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_mode_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_dev_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_off_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: 'time_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: 'time_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: 'time_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:188:17: error: '_dev_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '_ino_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '_mode_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '_dev_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '__off64_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: 'time_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: 'time_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: 'time_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_dev_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_ino_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_mode_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_dev_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__off64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__time64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__time64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__time64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 

Quando eseguo g ++ su un semplice file ciao mondo, funziona benissimo. Qualcuno sa cosa sta succedendo?

risposta

38

Ho anche aggiornato di recente MinGW e ho riscontrato problemi molto simili. Dopo alcune ricerche ho trovato this question on SO e ho provato a sostituire -std=c++11 con -std=gnu++11. Questo ha risolto il problema per me. Spero possa aiutare!

+2

Lukas - grazie! Questo era davvero il problema. Ora vedo che ho diverse versioni di MinGW su ciascuna macchina, qualcosa su cui avrei dovuto raccogliere. – Draknir

+5

Ho avuto questo problema con CLion. Ho dovuto modificare CMakeLists.txt e cambiare -std = C++ 11 in -std = gnu ++ 11 come hai menzionato Lukas. Grazie! – JDPeckham