gpt4 book ai didi

c++ - MinGW/CxxTest 奇怪的错误

转载 作者:IT老高 更新时间:2023-10-28 22:00:07 26 4
gpt4 key购买 nike

我希望你能帮助我。我在我的主要开发机器上使用 CxxTest 编写了一个小项目。在这台机器上一切正常,没有问题。但是,我尝试在我全新的笔记本电脑上设置这个项目,但无法让它工作!我怀疑我的 MinGW 安装而不是 CxxTest 出了问题,但这真的很难知道 - 错误来自 CxxTest 文件。这是项目的文件夹结构:

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

在我运行的命令行上:

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

这会生成 runner.cpp。现在我运行:

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

这通常可以正常工作,输出 runner.exe 并运行我的单元测试。在我的笔记本电脑上,我收到了数千个错误。以下是前几个:

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 );

当我在一个简单的 hello world 文件上运行 g++ 时,它运行良好。有谁知道怎么回事?

最佳答案

我最近也更新了 MinGW,遇到了非常相似的问题。经过一番研究,我发现 this question on SO并尝试将 -std=c++11 替换为 -std=gnu++11。这为我解决了这个问题。希望对您有所帮助!

关于c++ - MinGW/CxxTest 奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38436542/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com