1
0

Gcc.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4))
  18. #define Gcc_PRINTF( format_idx, arg_idx ) \
  19. __attribute__((__format__ (__printf__, format_idx, arg_idx)))
  20. #define Gcc_NORETURN \
  21. __attribute__((__noreturn__))
  22. #define Gcc_NONNULL(...) \
  23. __attribute__((__nonnull__(__VA_ARGS__)))
  24. #define Gcc_PURE \
  25. __attribute__ ((__pure__))
  26. #else
  27. #define Gcc_PRINTF( format_idx, arg_idx )
  28. #define Gcc_NORETURN
  29. #define Gcc_NONNULL(num)
  30. #define Gcc_PURE
  31. #endif
  32. #define Gcc_SHORT_FILE <?js return '"'+__FILE__.substring(__FILE__.lastIndexOf('/')+1)+'"'; ?>
  33. #define Gcc_FILE Gcc_SHORT_FILE
  34. #define Gcc_LINE __LINE__
  35. Gcc_PRINTF(1,2)
  36. static inline void Gcc_checkPrintf(const char* format, ...)
  37. {
  38. // This does nothing except to trigger warnings if the format is wrong.
  39. }
  40. #endif