The Fugue

Counterpoint by Hans Fugal

Zero Link

Posted by Hans Fugal Fri, 07 Apr 2006 21:43:00 GMT

XCode has a feature called Zero Link, which apparently more or less skips the linking step when you build your project. I don't know the details but it's probably fair to say that it's like just-in-time compiling, but for linking. The raison d'être of this feature is to reduce the time spent waiting for things to compile during development. It's not to be used for released code, so it is on by default in the development building style and off by default for the release style.

That sounds really neat, but we just wasted a bunch more time than we could possibly have saved with Zero Link, because there was no linker to complain about this:

// foo.h
#ifndef FOO_H
#define FOO_H

short foo[2];
short *p;

#endif

The problem, if you don't already see it, is that those variables should be declared extern and instantiated in one and only one .c file. ld would complain about duplicate symbols when trying to link two .o files that had both included this header file. But with Zero Link, there's no error. Instead, you get crazy behavior from the debugger: assignments that seem to have no effect and other odd things that make you think you've fallen into an alternate universe.

So be careful.

Posted in | no comments | Tags , , , , | atom

Comments

Leave a response

Leave a comment