c++ - 如何将 Eigen 库安装到 IAR c/c++ 编译器
问题描述
是否可以将用于线性代数的 C++ 模板库 Eigen 移植到 ARM 的 IAR 工作台。我曾尝试这样做,但出现以下编译错误
Error[Pe337]: linkage specification is incompatible with previous "__nounwind __iar_builtin_get_CONTROL" (declared at line 58 of "C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.3\arm\inc\c\iccarm_builtin.h") C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.3\arm\CMSIS\Core\Include\cmsis_gcc.h 151
这是我使用预处理器时遇到的全部错误
__GNUC__
__arm__
如果我不使用这些预处理器,我会从 Eigen 文件 Macros.h 的 #error 预处理器中得到一个错误
“错误请告诉我你的编译器的属性((aligned(n))) 的等价物是什么”
#if (defined __CUDACC__)
#define EIGEN_ALIGN_TO_BOUNDARY(n) __align__(n)
#elif EIGEN_COMP_GNUC || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM
#define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
#elif EIGEN_COMP_MSVC
#define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
#elif EIGEN_COMP_SUNCC
// FIXME not sure about this one:
#define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
#else
//#define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
#error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
#endif
我让它适用于视觉 c++,但不适用于 IAR。添加所有包含。
这些错误会根据我用来尝试配置 Eigen 的预处理器而变化。是否可以将 Eigen 与 IAR 一起使用?
解决方案
要添加到@chtz 答案,以下是我如何让 EIGEN_ALIGN_TO_BOUNDARY 宏与 IAR 一起使用,其方式与 eigen 库一致:
1:将此添加到 Macros.h 顶部以识别 IAR ARM 编译器
/// \internal EIGEN_COMP_ICCARM set to 1 if the compiler is IAR eWARM
#if defined(__ICCARM__)
#define EIGEN_COMP_ICCARM 1
#else
#define EIGEN_COMP_ICCARM 0
#endif
2:将此案例添加到在 Macros.h 中定义 EIGEN_ALIGN_TO_BOUNDARY(n) 的位置
#elif EIGEN_COMP_ICCARM
#define IAR_STRINGIFY(a) #a
#define IAR_ALIGN_STR(n) IAR_STRINGIFY(data_alignment=n)
#define EIGEN_ALIGN_TO_BOUNDARY(n) _Pragma(IAR_ALIGN_STR(n))
EIGEN_ALIGN_TO_BOUNDARY(n) 现在应该正确扩展为 _Pragma("data_alignment=n")
推荐阅读
- git - git pull 后恢复丢失的文件
- r - 如何在ggplot2中为多行添加标签?
- testing - 如何在运行 test cafe 的机器上检查下载的文件是否为扩展名 .zip
- javascript - Javascript 小书签图像下载损坏图像
- c# - 使用 ASP.NET 框架 4.6.1 和 Chrome 时未将 Cookie 设置到已部署的网站中
- discord.js - 数字组合生成器
- python-gitlab - 如何处理来自 python-gitlab api 请求的输出
- java - 与 Java 的 GeneralPath 等效的 c# 是什么?
- python - 将不同文件夹中的多个文本文件加载到一个文件中并考虑特殊字符
- debugging - 无法在 GDB 的 Rust 程序中获取“main”的当前行