Gcc.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Gcc_H
  16. #define Gcc_H
  17. #if !defined(__clang__) && \
  18. defined(__GNUC__) && \
  19. (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
  20. #define Gcc_PRINTF( format_idx, arg_idx ) \
  21. __attribute__((__format__ (__printf__, format_idx, arg_idx)))
  22. #define Gcc_NORETURN \
  23. __attribute__((__noreturn__))
  24. #define Gcc_NONNULL(...) \
  25. __attribute__((__nonnull__(__VA_ARGS__)))
  26. #define Gcc_PURE \
  27. __attribute__ ((__pure__))
  28. #define Gcc_PACKED \
  29. __attribute__ ((packed))
  30. #define Gcc_ALLOC_SIZE(...) \
  31. __attribute__ ((alloc_size(__VA_ARGS__)))
  32. #elif defined(__clang__)
  33. #define Gcc_NORETURN \
  34. __attribute__((__noreturn__))
  35. #endif
  36. #ifndef Gcc_PRINTF
  37. #define Gcc_PRINTF( format_idx, arg_idx )
  38. #endif
  39. #ifndef Gcc_NORETURN
  40. #define Gcc_NORETURN
  41. #endif
  42. #ifndef Gcc_NONNULL
  43. #define Gcc_NONNULL(...)
  44. #endif
  45. #ifndef Gcc_PURE
  46. #define Gcc_PURE
  47. #endif
  48. #ifndef Gcc_PACKED
  49. #define Gcc_PACKED
  50. #endif
  51. #ifndef Gcc_ALLOC_SIZE
  52. #define Gcc_ALLOC_SIZE(...)
  53. #endif
  54. #define Gcc_SHORT_FILE <?js return '"'+__FILE__.substring(__FILE__.lastIndexOf('/')+1)+'"'; ?>
  55. #define Gcc_FILE Gcc_SHORT_FILE
  56. #define Gcc_LINE __LINE__
  57. Gcc_PRINTF(1,2)
  58. static inline void Gcc_checkPrintf(const char* format, ...)
  59. {
  60. // This does nothing except to trigger warnings if the format is wrong.
  61. }
  62. #endif