我已经开始学习如何使用 Catch2 来测试我的 C++ 代码,并且正在尝试设置一个简单的测试。
我的文件夹结构由三个文件组成,它们都在同一个文件夹中:
catch.cpp //this is the catch_amalgamated.cpp file from GitHub
catch.hpp //this is the catch_amalgamated.hpp file from GitHub
test.cpp //this is my test file
我所写的test.cpp
是:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
当我尝试编译时,test.cpp
我收到以下错误,我认为这表明没有main()
找到函数(?):
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
当我添加一个标称main()
函数时,该文件编译成功,但据我所知,它#define CATCH_CONFIG_MAIN
应该为您创建main()
函数,所以显然有些东西不起作用。
任何人都可以对此有所了解吗?