Guest User

Untitled

a guest
Aug 10th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. programmatically mocking a function
  2. #include <stdio.h>
  3.  
  4. void someFunc( void )
  5. {
  6. printf("%s():%dn",__func__,__LINE__);
  7. }
  8.  
  9. void someBlah( void )
  10. {
  11. printf("%s():%dn",__func__,__LINE__);
  12. }
  13.  
  14. int main(void)
  15. {
  16. someFunc();
  17. }
  18.  
  19. #define BLAH 0
  20. #define FOO 1
  21. void (*table_function[])(void) = {someBlah, someFoo};
  22.  
  23. table_function[BLAH]();
  24.  
  25. table_function[BLAH] = otherBlah;
  26.  
  27. #include <stdio.h>
  28. #define DEBUG
  29.  
  30. void someFunc( void )
  31. {
  32. #ifndef DEBUG
  33. printf("%s():%dn",__func__,__LINE__);
  34. #else
  35. printf("%s():%dn",__func__,__LINE__);
  36. #endif
  37. }
  38.  
  39. int main(void)
  40. {
  41. someFunc();
  42. }
Add Comment
Please, Sign In to add comment