Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 当我使用CMake编译程序以捕获异常时,会发生编译错误。有人能帮我吗?_C++_Cmake_Compiler Errors - Fatal编程技术网

C++ 当我使用CMake编译程序以捕获异常时,会发生编译错误。有人能帮我吗?

C++ 当我使用CMake编译程序以捕获异常时,会发生编译错误。有人能帮我吗?,c++,cmake,compiler-errors,C++,Cmake,Compiler Errors,当我使用CMake编译我的程序时。我面临着这个错误 framework/base.h:146:30: 错误:expected unqualified-id before ‘&’ token catch(std::bad_typeid& e) 我的计划发布如下: void Do() { bool ret = false; try { ret = run(); }

当我使用CMake编译我的程序时。我面临着这个错误

framework/base.h:146:30: 错误:expected unqualified-id before ‘&’ token
         catch(std::bad_typeid& e)
我的计划发布如下:

 void Do()
    {        bool ret = false;
        try
        {
            ret = run();
        }
        catch(std::bad_typeid& e)
        {
            std::cerr << e.what() << '\n';
            errMsg = e.what();
            ret = false;
        }
        catch(...)
        {
            std::cerr << "unknown error" << '\n';
            errMsg = "unknown error";
            ret = false;
        }
    }
因为此函数在头文件中定义。其他一些模块包括此文件以使用函数do()。
因此,我只需在
CMakeLists.txt
中编写一个
include\u directories()
语句,然后通过include文件包含头文件
最后,它成功了。

欢迎使用堆栈溢出!请将CMake代码作为文本添加到您的问题帖子中。此外,请不要张贴代码的图像;相反,将源代码(以及完整的错误消息)作为文本添加到问题帖子中。考虑读取站点的一部分。虚空格DOOR(){BoOL ReT= false;尝试{Rt= Run();} catch(STD::BADYType ID和E){STD::Celr,你是否<代码> >包含< /代码>?这是我的函数的一部分,它在Windows中运行正常,但在Linux中失败。请提供一个。
include_directories(../common)