Guest User

Untitled

a guest
Jun 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. Bool NullFunc(const struct timespec *when, const char *who)
  2. {
  3. return TRUE;
  4. }
  5.  
  6. #define UNUSED(x) (void)(x)
  7.  
  8. void f(int x) {
  9. UNUSED(x);
  10. ...
  11. }
  12.  
  13. auto lambda = [](workerid_t workerId) -> void { };
  14.  
  15. auto lambda = [](__attribute__((unused)) _workerid_t workerId) -> void { } ;
  16.  
  17. #ifdef __GNUC__
  18. # define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
  19. #else
  20. # define UNUSED(x) UNUSED_ ## x
  21. #endif
  22.  
  23. #ifdef __GNUC__
  24. # define UNUSED_FUNCTION(x) __attribute__((__unused__)) UNUSED_ ## x
  25. #else
  26. # define UNUSED_FUNCTION(x) UNUSED_ ## x
  27. #endif
  28.  
  29. void foo(int UNUSED(bar)) { ... }
  30.  
  31. static void UNUSED_FUNCTION(foo)(int bar) { ... }
  32.  
  33. int foo (__attribute__((unused)) int bar) {
  34. return 0;
  35. }
  36.  
  37. void foo(int __attribute__((unused))key)
  38. {
  39. }
  40.  
  41. void foo(int key)
  42. {
  43. int hash = 0;
  44. int bkt __attribute__((unused)) = 0;
  45.  
  46. api_call(x, hash, bkt);
  47. }
  48.  
  49. #pragma GCC diagnostic push
  50. #pragma GCC diagnostic ignored "-Wunused-parameter"
  51. <code with unused parameters here>
  52. #pragma GCC diagnostic pop
  53.  
  54. If (MSVC)
  55. Set (CMAKE_EXE_LINKER_FLAGS "$ {CMAKE_EXE_LINKER_FLAGS} / NODEFAULTLIB: LIBCMT")
  56. Add_definitions (/W4 /wd4512 /wd4702 /wd4100 /wd4510 /wd4355 /wd4127)
  57. Add_definitions (/D_CRT_SECURE_NO_WARNINGS)
  58. Elseif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
  59. Add_definitions (-Wall -W -pedantic)
  60. Else ()
  61. Message ("Unknown compiler")
  62. Endif ()
  63.  
  64. if (when || who || format || data || len);
  65.  
  66. void foo(int x) {
  67. x; /* unused */
  68. ...
  69. }
Add Comment
Please, Sign In to add comment