Wrap many C calling functions to single implementation
``I have a requirement that the function call will have dif开发者_Python百科ferent names but all of them should refer to the same definition while executing. For example, i have a function calls like
UINT8 vsignal;UINT8 vsignal1;void Read_Message1_Signal1(&vSignal);void Read_Message2_Signal2(&vSignal1);
but this should be linked to
void Read_Message_Signal(UINT8 *signal){}
which is already implemented and compiled as a dll and should be linked to the different calls as those calls may vary based on the input.
Can anyone help me how to achieve this requirement?
Is there some reason you can't just write your own wrapper?
void Read_Message1_Signal1(&vSignal)
{
Read_Message_Signal(vSignal);
}
void Read_Message2_Signal2(&vSignal)
{
Read_Message_Signal(vSignal);
}
You can autogenerate these with a macro if there are a lot of them.
void Read_Message1_Signal1(&vSignal)
{
Read_Message_Signal(&vSignal); // or whatever
}
and repeat for your other function names, perhaps with a custom code generator.
You can use the preprocessor for that:
#define Read_Message1_Signal1(x) Read_Message_Signal(x)
#define Read_Message2_Signal2(x) Read_Message_Signal(x)
Or rethink your API, because this seems strange to me...
精彩评论