array.h headers 错误
Error with array.h headers
我使用 CLion,我有这个简单的代码:
#include <array>
int main() {
std::array<std::uint64_t, 3> arr;
return 0;
}
在我的 CMakeLists.txt
中,我尝试了从 c++11/gnu++11 到 c++17/gnu++17 的所有编译器标志,但是在尝试构建以上代码
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake --build
/pathToCLionProject/my_project/cmake-build-default --target my_project -- -j 2
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -H/pathToCLionProject/my_project -B/pathToCLionProject/my_project/cmake-build-default --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/gmake -f CMakeFiles/Makefile2 my_project
gmake[1]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -H/pathToCLionProject/my_project -B/pathToCLionProject/my_project/cmake-build-default --check-build-system CMakeFiles/Makefile.cmake 0
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -E cmake_progress_start /pathToCLionProject/my_project/cmake-build-default/CMakeFiles 2
/usr/bin/gmake -f CMakeFiles/Makefile2 CMakeFiles/my_project.dir/all
gmake[2]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
/usr/bin/gmake -f CMakeFiles/my_project.dir/build.make CMakeFiles/my_project.dir/depend
gmake[3]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
cd /pathToCLionProject/my_project/cmake-build-default && /pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -E cmake_depends "Unix Makefiles" /pathToCLionProject/my_project /pathToCLionProject/my_project /pathToCLionProject/my_project/cmake-build-default /pathToCLionProject/my_project/cmake-build-default /pathToCLionProject/my_project/cmake-build-default/CMakeFiles/my_project.dir/DependInfo.cmake --color=
Scanning dependencies of target my_project
gmake[3]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
/usr/bin/gmake -f CMakeFiles/my_project.dir/build.make CMakeFiles/my_project.dir/build
gmake[3]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
[ 50%] Building CXX object CMakeFiles/my_project.dir/dev/hmmenc_client/test.cpp.o
/usr/bin/c++ -I/pathToCLionProject/my_project -I/pathToCLionProject/my_project/dev/hmmenc_client -I/usr/local/include/pqxx -I/usr/pgsql-10/include -pthread -std=gnu++11 -o CMakeFiles/my_project.dir/dev/hmmenc_client/test.cpp.o -c /pathToCLionProject/my_project/dev/hmmenc_client/test.cpp
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp: In function ‘int main()’:
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:10: error: ‘array’ is not a member of ‘std’
std::array<std::uint64_t, 3> arr;
^~~~~
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:10: note: ‘std::array’ is defined in header ‘<array>’; did you forget to ‘#include <array>’?
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:6:1:
+#include <array>
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:10:
std::array<std::uint64_t, 3> arr;
^~~~~
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:29: error: expected primary-expression before ‘,’ token
std::array<std::uint64_t, 3> arr;
^
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:34: error: ‘arr’ was not declared in this scope
std::array<std::uint64_t, 3> arr;
^~~
gmake[3]: *** [CMakeFiles/my_project.dir/build.make:66: CMakeFiles/my_project.dir/dev/hmmenc_client/test.cpp.o] Error 1
gmake[3]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
gmake[2]: *** [CMakeFiles/Makefile2:71: CMakeFiles/my_project.dir/all] Error 2
gmake[2]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/my_project.dir/rule] Error 2
gmake[1]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
gmake: *** [Makefile:121: my_project] Error 2
这是我的 g++ 版本:gcc 版本 8.1.1 20180502 (Red Hat 8.1.1-1) (GCC)。什么会导致此错误?
如果包含路径(/pathToCLionProject/my_project
、/pathToCLionProject/my_project/dev/hmmenc_client
、/usr/local/include/pqxx
、/usr/pgsql-10/include
).
我使用 CLion,我有这个简单的代码:
#include <array>
int main() {
std::array<std::uint64_t, 3> arr;
return 0;
}
在我的 CMakeLists.txt
中,我尝试了从 c++11/gnu++11 到 c++17/gnu++17 的所有编译器标志,但是在尝试构建以上代码
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake --build
/pathToCLionProject/my_project/cmake-build-default --target my_project -- -j 2
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -H/pathToCLionProject/my_project -B/pathToCLionProject/my_project/cmake-build-default --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/gmake -f CMakeFiles/Makefile2 my_project
gmake[1]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -H/pathToCLionProject/my_project -B/pathToCLionProject/my_project/cmake-build-default --check-build-system CMakeFiles/Makefile.cmake 0
/pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -E cmake_progress_start /pathToCLionProject/my_project/cmake-build-default/CMakeFiles 2
/usr/bin/gmake -f CMakeFiles/Makefile2 CMakeFiles/my_project.dir/all
gmake[2]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
/usr/bin/gmake -f CMakeFiles/my_project.dir/build.make CMakeFiles/my_project.dir/depend
gmake[3]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
cd /pathToCLionProject/my_project/cmake-build-default && /pathToCLion/clion-2018.1.2/bin/cmake/bin/cmake -E cmake_depends "Unix Makefiles" /pathToCLionProject/my_project /pathToCLionProject/my_project /pathToCLionProject/my_project/cmake-build-default /pathToCLionProject/my_project/cmake-build-default /pathToCLionProject/my_project/cmake-build-default/CMakeFiles/my_project.dir/DependInfo.cmake --color=
Scanning dependencies of target my_project
gmake[3]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
/usr/bin/gmake -f CMakeFiles/my_project.dir/build.make CMakeFiles/my_project.dir/build
gmake[3]: Entering directory '/pathToCLionProject/my_project/cmake-build-default'
[ 50%] Building CXX object CMakeFiles/my_project.dir/dev/hmmenc_client/test.cpp.o
/usr/bin/c++ -I/pathToCLionProject/my_project -I/pathToCLionProject/my_project/dev/hmmenc_client -I/usr/local/include/pqxx -I/usr/pgsql-10/include -pthread -std=gnu++11 -o CMakeFiles/my_project.dir/dev/hmmenc_client/test.cpp.o -c /pathToCLionProject/my_project/dev/hmmenc_client/test.cpp
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp: In function ‘int main()’:
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:10: error: ‘array’ is not a member of ‘std’
std::array<std::uint64_t, 3> arr;
^~~~~
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:10: note: ‘std::array’ is defined in header ‘<array>’; did you forget to ‘#include <array>’?
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:6:1:
+#include <array>
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:10:
std::array<std::uint64_t, 3> arr;
^~~~~
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:29: error: expected primary-expression before ‘,’ token
std::array<std::uint64_t, 3> arr;
^
/pathToCLionProject/my_project/dev/hmmenc_client/test.cpp:9:34: error: ‘arr’ was not declared in this scope
std::array<std::uint64_t, 3> arr;
^~~
gmake[3]: *** [CMakeFiles/my_project.dir/build.make:66: CMakeFiles/my_project.dir/dev/hmmenc_client/test.cpp.o] Error 1
gmake[3]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
gmake[2]: *** [CMakeFiles/Makefile2:71: CMakeFiles/my_project.dir/all] Error 2
gmake[2]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/my_project.dir/rule] Error 2
gmake[1]: Leaving directory '/pathToCLionProject/my_project/cmake-build-default'
gmake: *** [Makefile:121: my_project] Error 2
这是我的 g++ 版本:gcc 版本 8.1.1 20180502 (Red Hat 8.1.1-1) (GCC)。什么会导致此错误?
如果包含路径(/pathToCLionProject/my_project
、/pathToCLionProject/my_project/dev/hmmenc_client
、/usr/local/include/pqxx
、/usr/pgsql-10/include
).