c - enum_is_int 选项

标签 c linker makefile arm armcc

我目前使用arm env 在Intel x118 平台上工作。我发现必须强制打开这个选项才能确保链接没有问题,否则会出现如下错误:

Error: L6242E: Cannot link object iui_os_irq_msk.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object iui_os.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_critical_section.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_thread.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_event.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_event_group.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_queue.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_sem.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_common.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Error: L6242E: Cannot link object uta_os_mem.o as its attributes are incompatible with the image attributes.
   ... packed-enum clashes with enum_is_int.
Not enough information to list image symbols.
Not enough information to list the image map.
Finished: 13 information, 0 warning and 11 error messages.

谁能告诉我,这个--enum_is_int选项是否对我的目标文件产生重大影响?

更多信息:

我发现了一些关于 ARM 的评论:

--enum_is_int

此选项强制所有枚举类型的大小至少为四个字节。

此选项默认关闭,并使用可以容纳所有枚举器值的最小数据类型。

如果您在命令行中指定 ARM Linux 配置文件,则默认打开此选项。

注意 不建议将 --enum_is_int 选项用于一般用途。

最佳答案

该选项可能会稍微增加代码的内存占用量,但可能不会显着增加。它可以安全使用,并且在这种情况下是必需的,因为链接器不会链接被认为不兼容的对象。

也就是说,您可以使用 --diag-warning=6242 命令行选项覆盖链接器错误,但生成的图像可能无法正常工作。

关于c - enum_is_int 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12453241/

相关文章:

c++ - 是否有任何教程可以帮助精通 c++ 的程序员学习 c?

dll - 不一致的dll链接

无法使用在 Ubuntu 上链接的 SDL 库编译文件

c - 静态与动态链接

在 Linux 中使用 makefile 包含 math.h 时无法编译 C 源文件

c - 对已链接的函数的 undefined reference

bash - 在 Go makefile 中使用 bash 命令

c - 从文本文件中读取结构

c - 填充整数数组与填充 float 组相同吗?

C - free() 后内存发生了什么?