I ran into portability issue on Linux due to a type change in the system header. The siginfo_t type has been changed from a named structure (struct siginfo) to an unnamed structure. For me, this has changed between RHEL6 and RHEL7.
We use ACE in several places, and they have siginfo_t in several publicly accessible interfaces. As a result, code compiled on RHEL7 will not be linked to a library built on RHEL6. Currently I need to support this.
In RHEL6, one task function is typed as:
ACE_Event_Handler::handle_signal(int, siginfo*, ucontext*)
In RHEL7, it looks like this:
ACE_Event_Handler::handle_signal(int, siginfo_t*, ucontext*)
They fall into different characters, which leads to a failure when linking or to fail to find a character at runtime.
A relatively simple solution is to use a function alias. However, I do not want to modify the header file. I'm struggling a bit because it is a virtual member function.
I tried to do this in Event_Handler.cpp in the ACE version built on RHEL7:
struct siginfo;
ACE_Event_Handler::handle_signal(int, siginfo*, ucontext*)
__attribute__((
alias("_ZN17ACE_Event_Handler13handle_signalEiP9siginfo_tP8ucontext")
));
However, the GCC complains that the function has not been declared. In the end, I was able to do this work, but only with this ugly hack:
extern "C" int _ZN17ACE_Event_Handler13handle_signalEiP7siginfoP8ucontext()
__attribute__((
alias("_ZN17ACE_Event_Handler13handle_signalEiP9siginfo_tP8ucontext")
));
"extern" C "'is necessary to prevent the reassignment of a malformed name.
Is there a more elegant way to do this without triggering compiler complaints?