Thu 11 Aug 2016 01:39:13 AM UTC, original submission:
In libunwind, function is independent on architecture by defining function as macro.
e.g. in x86_64 processor:
unw_getcontext
-> unw_tdep_getcontext
-> UNW_ARCH_OBJ(getcontext)
-> UNW_PASTE(UNW_PASTE(UNW_PASTE(U,UNW_TARGET),), getcontext)
And macro UNW_TARGET is architecture(x86_64), therefore:
-> _Ux86_64_getcontext
This technique works at the most of projects, but in some projects architecture is set directly to preprocessor as an argument "-Dx86_64".
Passing "-Dx86_64" to compiler is equivalent to:
#define x86_64 1
And this causes
#define UNW_TARGET x86_64
-> 1
So, in this case, unw_getcontext is expanded to _U1_getcontext.
I suggest that this project should has own prefix for target.
How about updating definition of preprocessor macro like:
#define UNW_TARGET _Ux86_64
#define UNW_ARCH_OBJ(fn) UNW_PASTE(UNW_TARGET,_),fn)
This never occurs any conflicts, I think.
|