简体   繁体   English

在静态库中使用宏进行函数声明和定义对符号导出的影响

[英]effect of using macros for function declaration and definition on symbol export within a static library

Does anyone know if the extensive use of c-macros to define and declare functions when building a static library affects the linker's ability to export those symbols? 有谁知道在构建静态库时大量使用c-macros定义和声明函数是否会影响链接程序导出这些符号的能力?

I have consistently run into this issue and almost always most of the symbol lookup failures went away when I switched to regular function declaration and definition (no usage of macros). 我一直遇到这个问题,当我切换到常规函数声明和定义(不使用宏)时,几乎所有符号查找失败都几乎消失了。

This happens on the mac platform using Xcode 5 and targeting iOS (arm + i386). 这是在使用Xcode 5并针对iOS(arm + i386)的mac平台上发生的。

It did not matter which build settings i turned on/off. 我打开/关闭哪个构建设置都没有关系。 What seems to make a real difference is the usage of macros and the use of a symbol export file. 看起来真正有所不同的是宏的使用和符号导出文件的使用。

I ask because I am now up against a big, big chunk of code that uses several levels of macros for function definitions and declarations and I don't want to change that unless I absolutely have to. 我问,因为我现在遇到了一大堆代码,这些代码使用几个级别的宏进行函数定义和声明,并且除非绝对必要,否则我不想更改它。

The code is really complex (but compelling :) ) and was originally built using GNU make & siblings. 该代码确实很复杂(但引人注目:)),最初是使用GNU make&siblings构建的。 So, switching it to XCode-based builds is no walk in the park. 因此,将其切换到基于XCode的版本并不是一件容易的事。 It plays tricks with header includes. 它与标头包括一起玩把戏。

I would appreciate some education with respect to this point: macros & symbol exports for static libraries. 关于这一点,我将不胜感激:静态库的宏和符号导出。

Thanks! 谢谢!

Macros are expanded before the compiler kicks in, and the linker doesn't show up until all the object files are finished. 宏会在编译器启动之前展开,并且链接器直到所有目标文件完成后才会显示。 So, either your macros don't generate the code you think they do, or you have discovered the first macro to ever achieve time travel. 因此,要么您的宏没有生成您认为的代码,要么您发现了第一个实现时间转换的宏。 Edit: or I completely missed the point, as can be. 编辑:或者我完全不了解要点,可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM