For one of my classes, we've been using a linker hack to link two
libraries with the same function names. It did this by doing something
like this:
library1.h - has function()
library1.a - implements function() from library1.h
library2.h - has function()
library2.a - implements function() from library2.h
file1.cc - includes library1.h, uses its function()
file2.cc - includes library2.h, uses its function()
main.cc - Executes functions in file1 and file2.
Then:
g++ main.o file1.o file2.o -lrary2 -lrary1
and somehow everything compiles. Whether it works correctly (calls the
expected function() calls) or not is another matter, and that's what I'm
trying to find out -- is there a defined behavior when you do
this? Anyone know how this linker hack works? Does it make use of
function overloading in C++?
(Of course, I'm assuming this is a "hack." It's a technique I've
certainly never used or heard of.)
-Mark
---
Mark K. Kim
http://www.cbreak.org/mark/
PGP key available upon request.