SHARE
TWEET

Untitled

quantumech Apr 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <emscripten.h>
  4.  
  5. // Define a type for a function pointer that retruns an integer and takes no arguements
  6. typedef int (*intFPtr)();
  7.  
  8. // This method gets called by JS as a way to pass in the address of the JS method
  9. EMSCRIPTEN_KEEPALIVE
  10. void callFuncPtr(int rawFuncAddr)
  11. {
  12.     // Cast address to function pointer
  13.     intFPtr func = (intFPtr)(rawFuncAddr);
  14.  
  15.     // Invoke the function pointer and print its result
  16.     printf("%d\n", func());
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top