Guest User

Untitled

a guest
Mar 22nd, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. utils_api.h:
  2.  
  3. int (* add)(int a, int b);
  4. int (* sub)(int a, int b);
  5. void (* print)(const char*);
  6. float(* div)(float a, float b);
  7.  
  8. utils_wrap.h
  9. X(add)
  10. X(sub)
  11. X(print)
  12. X(float)
  13.  
  14. main.cpp:
  15.  
  16. #include <iostream>
  17. #include <dlfcn.h>
  18. #include "utils_api.h"
  19. int main(){
  20. void *hndl = dlopen ("utils.so", RTLD_LAZY);
  21. // Pull the API.
  22. #define X(N) \
  23. N = (typeof (N))dlsym(hndl, #N); \
  24. if (N == 0) \
  25. std::cout << ("Missing API " #N " in DLL.");
  26. #include "utils_wrap.h"
  27. #undef X
  28.  
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment