Sunday, December 27, 2009

link once (simulating c++ template code in pure c with GCC extensions)

The following definition will be merged in all compiled object files, i.e. the first function implementation will be linked into the produced binary and the following copies rejected.


__attribute__((section(".gnu.linkonce.c"))) int commonFunc(int a, int b) {
return a-b;
}

No comments: