Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- utils_api.h:
- int (* add)(int a, int b);
- int (* sub)(int a, int b);
- void (* print)(const char*);
- float(* div)(float a, float b);
- utils_wrap.h
- X(add)
- X(sub)
- X(print)
- X(float)
- main.cpp:
- #include <iostream>
- #include <dlfcn.h>
- #include "utils_api.h"
- int main(){
- void *hndl = dlopen ("utils.so", RTLD_LAZY);
- // Pull the API.
- #define X(N) \
- N = (typeof (N))dlsym(hndl, #N); \
- if (N == 0) \
- std::cout << ("Missing API " #N " in DLL.");
- #include "utils_wrap.h"
- #undef X
- return 0;
- }
Add Comment
Please, Sign In to add comment