KrzysztofRosinski
asked on
Linux proxy library (between two libraries)
Hello,
I need to create library which will be like proxy between two other libraries. Exactly I have one high level library which use low level library. I would like to create small lib that implements all functions from low-level lib; do some job and call real method from low-level library. And I don't known how to comile something like this, without problems with repeat function names.
Example:
void function(void) {
do_something();
function(); // low level library
}
I figured that I could wrap low level functions e.g.
void wrap_function(void) {
function();
}
And then use it in proxy library:
void function(void) {
wrap_function();
}
But when I'm trying to run this I'm getting Segmentation fault because functions are looping:
(gdb) bt
#0 nfc_version () at main.c:5
#1 0x00000000004011fb in wrap_nfc_version ()
#2 0x0000000000400ddd in nfc_version () at main.c:5
#3 0x00000000004011fb in wrap_nfc_version ()
#4 0x0000000000400ddd in nfc_version () at main.c:5
#5 0x00000000004011fb in wrap_nfc_version ()
#6 0x0000000000400ddd in nfc_version () at main.c:5
#7 0x00000000004011fb in wrap_nfc_version ()
#8 0x0000000000400ddd in nfc_version () at main.c:5
#9 0x00000000004011fb in wrap_nfc_version ()
#10 0x0000000000400ddd in nfc_version () at main.c:5
#11 0x00000000004011fb in wrap_nfc_version ()
#12 0x0000000000400ddd in nfc_version () at main.c:5
#13 0x00000000004011fb in wrap_nfc_version ()
#14 0x0000000000400ddd in nfc_version () at main.c:5
(...)
Do you have any ideas how to solve this problem ?
I need to create library which will be like proxy between two other libraries. Exactly I have one high level library which use low level library. I would like to create small lib that implements all functions from low-level lib; do some job and call real method from low-level library. And I don't known how to comile something like this, without problems with repeat function names.
Example:
void function(void) {
do_something();
function(); // low level library
}
I figured that I could wrap low level functions e.g.
void wrap_function(void) {
function();
}
And then use it in proxy library:
void function(void) {
wrap_function();
}
But when I'm trying to run this I'm getting Segmentation fault because functions are looping:
(gdb) bt
#0 nfc_version () at main.c:5
#1 0x00000000004011fb in wrap_nfc_version ()
#2 0x0000000000400ddd in nfc_version () at main.c:5
#3 0x00000000004011fb in wrap_nfc_version ()
#4 0x0000000000400ddd in nfc_version () at main.c:5
#5 0x00000000004011fb in wrap_nfc_version ()
#6 0x0000000000400ddd in nfc_version () at main.c:5
#7 0x00000000004011fb in wrap_nfc_version ()
#8 0x0000000000400ddd in nfc_version () at main.c:5
#9 0x00000000004011fb in wrap_nfc_version ()
#10 0x0000000000400ddd in nfc_version () at main.c:5
#11 0x00000000004011fb in wrap_nfc_version ()
#12 0x0000000000400ddd in nfc_version () at main.c:5
#13 0x00000000004011fb in wrap_nfc_version ()
#14 0x0000000000400ddd in nfc_version () at main.c:5
(...)
Do you have any ideas how to solve this problem ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yep, this solution is correct, I finally did it yesterday evning and it is exacely what I need.
Thanks Guys.
Thanks Guys.
That's called a wrapper. Your wrapper library will have to use different function names than the ones from the existing library.
Your code will then make calls to the functions implemented in the wrapper library.
Open in new window