warn-on-use.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef _GL_WARN_ON_USE
  2. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  3. /* A compiler attribute is available in gcc versions 4.3.0 and later. */
  4. # define _GL_WARN_ON_USE(function, message) \
  5. extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
  6. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  7. /* Verify the existence of the function. */
  8. # define _GL_WARN_ON_USE(function, message) \
  9. extern __typeof__ (function) function
  10. # else /* Unsupported. */
  11. # define _GL_WARN_ON_USE(function, message) \
  12. _GL_WARN_EXTERN_C int _gl_warn_on_use
  13. # endif
  14. #endif
  15. /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
  16. is like _GL_WARN_ON_USE (function, "string"), except that the function is
  17. declared with the given prototype, consisting of return type, parameters,
  18. and attributes.
  19. This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
  20. not work in this case. */
  21. #ifndef _GL_WARN_ON_USE_CXX
  22. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  23. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  24. extern rettype function parameters_and_attributes \
  25. __attribute__ ((__warning__ (msg)))
  26. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  27. /* Verify the existence of the function. */
  28. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  29. extern rettype function parameters_and_attributes
  30. # else /* Unsupported. */
  31. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  32. _GL_WARN_EXTERN_C int _gl_warn_on_use
  33. # endif
  34. #endif
  35. /* _GL_WARN_EXTERN_C declaration;
  36. performs the declaration with C linkage. */
  37. #ifndef _GL_WARN_EXTERN_C
  38. # if defined __cplusplus
  39. # define _GL_WARN_EXTERN_C extern "C"
  40. # else
  41. # define _GL_WARN_EXTERN_C extern
  42. # endif
  43. #endif