在我当前的项目中,我正在使用 arpackpp 界面。整个库都写在.h
文件中,所以不需要编译库。我现在面临的问题 - 当我在我的一些arpackpp
文件中包含一些头文件时main.cpp
,我收到以下错误:
/.../Files/Includes/../../../arpack++/include/arerror.h:163: 多重定义
ArpackError::Set(ArpackError::ErrorCode, std::string const&)' /.../Files/Includes/../../../arpack++/include/arerror.h:163: first defined here /tmp/ccruWhMn.o: In function
std::iterator_traits::iterator_category std::__iterator_category(char* const&)': / .../Files/Includes/../../../arpack++/include/arerror.h:163:ArpackError::code' /.../Files/Includes/../../../arpack++/include/arerror.h:163: first defined here /tmp/ccruWhMn.o: In function
std::vector >::max_size() const' 的多重定义:
arpackpp
链接所有.o
文件时的几个功能。正如我在几个线程中所读到的,问题在于我实际上包含了函数的实例化,这通常应该避免。因为我不想更改整个库,所以我使用arpackpp
了类 in包含了所有类和函数main.cpp
,这变得非常混乱。这个问题有解决方法吗?为什么不包括警卫来(#ifndef...#endif)
防止这个问题?