unused.h 948 B

1234567891011121314151617181920212223242526
  1. /// \file
  2. /// \brief abstraction for squashing compiler warnings for unused symbols
  3. /// \ingroup cgraph_utils
  4. #pragma once
  5. /// squash an unused variable/function warning in C
  6. ///
  7. /// e.g.
  8. ///
  9. /// static UNUSED void my_uncalled_function(void) { }
  10. /// static UNUSED int my_unused_variable;
  11. ///
  12. /// Use this sparingly, as the MSVC version applies to everything in both the
  13. /// current and next line, so can end up accidentally masking genuine problems.
  14. #ifdef __GNUC__ // Clang and GCC
  15. #define UNUSED __attribute__((unused))
  16. #elif defined(_MSC_VER) // MSVC
  17. #define UNUSED \
  18. __pragma(warning(suppress : 4100 /* unreferenced formal parameter */ \
  19. 4101 /* unreferenced local variable */ \
  20. 4505 /* unreferenced local function */ \
  21. ))
  22. #else
  23. #define UNUSED /* nothing */
  24. #endif