tst-wmemstream1.c 944 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <wchar.h>
  2. extern int fclose (FILE*);
  3. #if defined __GNUC__ && __GNUC__ >= 11
  4. /* Verify that calling fclose on the result of open_wmemstream doesn't
  5. trigger GCC -Wmismatched-dealloc with fclose forward-declared and
  6. without <stdio.h> included first (it is included later, in.
  7. "tst-memstream1.c"). */
  8. #pragma GCC diagnostic push
  9. #pragma GCC diagnostic error "-Wmismatched-dealloc"
  10. #endif
  11. int test_open_wmemstream_no_stdio (void)
  12. {
  13. {
  14. wchar_t *buf;
  15. size_t size;
  16. FILE *f = open_wmemstream (&buf, &size);
  17. fclose (f);
  18. }
  19. {
  20. FILE* (*pf)(wchar_t**, size_t*) = open_wmemstream;
  21. wchar_t *buf;
  22. size_t size;
  23. FILE *f = pf (&buf, &size);
  24. fclose (f);
  25. }
  26. return 0;
  27. }
  28. #if defined __GNUC__ && __GNUC__ >= 11
  29. /* Restore -Wmismatched-dealloc setting. */
  30. # pragma GCC diagnostic pop
  31. #endif
  32. #define CHAR_T wchar_t
  33. #define W(o) L##o
  34. #define OPEN_MEMSTREAM open_wmemstream
  35. #include "tst-memstream1.c"