array.h标头出错

时间:2018-06-17 20:58:09

标签: c++ c++11 cmake g++ clion

我使用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)。什么可能导致此错误?

1 个答案:

答案 0 :(得分:0)

如果在包含路径(array/pathToCLionProject/my_project /pathToCLionProject/my_project/dev/hmmenc_client,{{1}上列出的任何目录中都有一个名为/usr/local/include/pqxx的空文件,则会出现此错误})。