因此,当我尝试构建c ++应用程序时,在以下代码段中会出现编译时错误
static_assert(sizeof(int32_t) == 4)
这是我得到expected string-literal before ‘)’
在一些调查中,我发现static_assert在c ++ 11中需要一个消息参数,而在c ++ 17中已将其消除。看起来我的应用程序正在为c ++ 11编译吗?
在我的CMakeLists.txt文件中,以下几行
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
以上几行不是应该为c ++ 17构建我的应用程序吗?
谢谢!
Update1-完整错误跟踪
In file included from <project_root>/src/include/buffer/buffer_pool_manager.h:22:0,
from <project_root>/src/include/catalog/simple_catalog.h:8,
from <project_root>/src/include/catalog/table_generator.h:6,
from <project_root>/src/catalog/table_generator.cpp:1:
<project_root>/src/include/storage/page/page.h:70:39: error: expected ‘,’ before ‘)’ token
static_assert(sizeof(page_id_t) == 4);
^
<project_root>/src/include/storage/page/page.h:70:39: error: expected string-literal before ‘)’ token
In file included from <project_root>/src/include/buffer/buffer_pool_manager.h:22:0,
from <project_root>/src/buffer/buffer_pool_manager.cpp:13:
<project_root>/src/include/storage/page/page.h:70:39: error: expected ‘,’ before ‘)’ token
static_assert(sizeof(page_id_t) == 4);
^
<project_root>/src/include/storage/page/page.h:70:39: error: expected string-literal before ‘)’ token
src/CMakeFiles/bustub_shared.dir/build.make:62: recipe for target 'src/CMakeFiles/bustub_shared.dir/buffer/buffer_pool_manager.cpp.o' failed
make[2]: *** [src/CMakeFiles/bustub_shared.dir/buffer/buffer_pool_manager.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
src/CMakeFiles/bustub_shared.dir/build.make:114: recipe for target 'src/CMakeFiles/bustub_shared.dir/catalog/table_generator.cpp.o' failed
make[2]: *** [src/CMakeFiles/bustub_shared.dir/catalog/table_generator.cpp.o] Error 1
CMakeFiles/Makefile2:383: recipe for target 'src/CMakeFiles/bustub_shared.dir/all' failed
make[1]: *** [src/CMakeFiles/bustub_shared.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
答案 0 :(得分:1)
我将其更改为gcc-7,而g ++-7解决了我的问题。