gpt4 book ai didi

c++ - 编译使用 "Meschach"库的模块时从 STL 抛出的错误

转载 作者:行者123 更新时间:2023-11-30 04:39:24 25 4
gpt4 key购买 nike

我正在开发一个使用共享库的模块,而共享库又链接了一个静态库。共享库构建工作正常并生成一个 .so。当我尝试在模块中使用它时,在编译阶段出现了各种错误,其中大部分是基于 STL(具体来说是 STL 集合)。错误看起来像:

In file included from /usr/include/c++/4.3/list:68,                             
from /home/gayan/LHIMo/LHI/src/CalcEngine/include/JuncNodeInfo.h:11,
from /home/gayan/LHIMo/LHI/src/CalcEngine/include/RiverFlowParameter.h:11,
from Main.cpp:11:
/usr/include/c++/4.3/bits/stl_list.h:465:11: error: macro "catch" requires 3 arguments, but only 1 given

这在大多数使用列表、 vector 或 map 的地方都给出了。请帮我解决这个问题。

示例代码:库中的“CalcEngine.h”:

#ifndef LHI_CALCENGINE_H_
#define LHI_CALCENGINE_H_

extern "C"{
#include <matrix2.h>
}

class CalcEngine{

public:

protected:

};


#endif /* LHI_CALCENGINE_H_ */

应用程序中的Main.cpp:

#include <iostream>
#include <CalcEngine.h>
#include <list> // The compilation fails as soon as this is added

int main(int argc, char** argv){

return -1;
}

我觉得这与 matrix2.h 文件有关,但无法确定。可以找到该文件 here

最佳答案

谷歌搜索似乎 Meschach 库有一个名为 catch 的宏(定义为 err.h,间接包含在 matrix2.h 中)导致具有异常捕获的 C++ 代码失败。尝试

#undef catch 

在完成包含 meschach header 后,看看是否效果更好。

关于c++ - 编译使用 "Meschach"库的模块时从 STL 抛出的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2263960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com