0

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?

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).

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. So, switching it to XCode-based builds is no walk in the park. It plays tricks with header includes.

I would appreciate some education with respect to this point: macros & symbol exports for static libraries.

Thanks!

2
  • Just avoid macros. They have lots of problems. Use them for the simple stuff and let the compiler do its business. It has a better understanding of the language Commented May 30, 2014 at 18:41
  • @EdHeal I would love to avoid macros all together. I actually did in a different codebase for a simpler lib. The problem is that with this complex codebase which I inherited, the use of macros is EXTENSIVE and I am leery of making drastic changes when I don't yet have a full handle on the code. Commented May 31, 2014 at 1:39

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

My understanding is EXACTLY like yours. The reason i posted the question is that that same code with those same macros build successfully as an application using make tools. But when I use Xcode and convert the code to build a static library, these problems arise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.