compile_fail-printf.c 694 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright 2011 Rusty Russell
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option) any
  7. * later version. See LICENSE for more details.
  8. */
  9. #include <ccan/compiler/compiler.h>
  10. static void PRINTF_FMT(2,3) my_printf(int x, const char *fmt, ...)
  11. {
  12. }
  13. int main(int argc, char *argv[])
  14. {
  15. unsigned int i = 0;
  16. my_printf(1, "Not a pointer "
  17. #ifdef FAIL
  18. "%p",
  19. #if !HAVE_ATTRIBUTE_PRINTF
  20. #error "Unfortunately we don't fail if !HAVE_ATTRIBUTE_PRINTF."
  21. #endif
  22. #else
  23. "%i",
  24. #endif
  25. i);
  26. return 0;
  27. }