cstdio 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_CSTDIO
  10. #define _LIBCPP_CSTDIO
  11. /*
  12. cstdio synopsis
  13. Macros:
  14. BUFSIZ
  15. EOF
  16. FILENAME_MAX
  17. FOPEN_MAX
  18. L_tmpnam
  19. NULL
  20. SEEK_CUR
  21. SEEK_END
  22. SEEK_SET
  23. TMP_MAX
  24. _IOFBF
  25. _IOLBF
  26. _IONBF
  27. stderr
  28. stdin
  29. stdout
  30. namespace std
  31. {
  32. Types:
  33. FILE
  34. fpos_t
  35. size_t
  36. int remove(const char* filename);
  37. int rename(const char* old, const char* new);
  38. FILE* tmpfile(void);
  39. char* tmpnam(char* s);
  40. int fclose(FILE* stream);
  41. int fflush(FILE* stream);
  42. FILE* fopen(const char* restrict filename, const char* restrict mode);
  43. FILE* freopen(const char* restrict filename, const char * restrict mode,
  44. FILE * restrict stream);
  45. void setbuf(FILE* restrict stream, char* restrict buf);
  46. int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
  47. int fprintf(FILE* restrict stream, const char* restrict format, ...);
  48. int fscanf(FILE* restrict stream, const char * restrict format, ...);
  49. int printf(const char* restrict format, ...);
  50. int scanf(const char* restrict format, ...);
  51. int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
  52. int sprintf(char* restrict s, const char* restrict format, ...);
  53. int sscanf(const char* restrict s, const char* restrict format, ...);
  54. int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
  55. int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
  56. int vprintf(const char* restrict format, va_list arg);
  57. int vscanf(const char* restrict format, va_list arg); // C99
  58. int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
  59. va_list arg);
  60. int vsprintf(char* restrict s, const char* restrict format, va_list arg);
  61. int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
  62. int fgetc(FILE* stream);
  63. char* fgets(char* restrict s, int n, FILE* restrict stream);
  64. int fputc(int c, FILE* stream);
  65. int fputs(const char* restrict s, FILE* restrict stream);
  66. int getc(FILE* stream);
  67. int getchar(void);
  68. char* gets(char* s); // removed in C++14
  69. int putc(int c, FILE* stream);
  70. int putchar(int c);
  71. int puts(const char* s);
  72. int ungetc(int c, FILE* stream);
  73. size_t fread(void* restrict ptr, size_t size, size_t nmemb,
  74. FILE* restrict stream);
  75. size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
  76. FILE* restrict stream);
  77. int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
  78. int fseek(FILE* stream, long offset, int whence);
  79. int fsetpos(FILE*stream, const fpos_t* pos);
  80. long ftell(FILE* stream);
  81. void rewind(FILE* stream);
  82. void clearerr(FILE* stream);
  83. int feof(FILE* stream);
  84. int ferror(FILE* stream);
  85. void perror(const char* s);
  86. } // std
  87. */
  88. #include <__assert> // all public C++ headers provide the assertion handler
  89. #include <__config>
  90. #include <stdio.h>
  91. #ifndef _LIBCPP_STDIO_H
  92. # error <cstdio> tried including <stdio.h> but didn't find libc++'s <stdio.h> header. \
  93. This usually means that your header search paths are not configured properly. \
  94. The header search paths should contain the C++ Standard Library headers before \
  95. any C Standard Library, and you are probably using compiler flags that make that \
  96. not be the case.
  97. #endif
  98. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  99. # pragma GCC system_header
  100. #endif
  101. _LIBCPP_BEGIN_NAMESPACE_STD
  102. using ::FILE _LIBCPP_USING_IF_EXISTS;
  103. using ::fpos_t _LIBCPP_USING_IF_EXISTS;
  104. using ::size_t _LIBCPP_USING_IF_EXISTS;
  105. using ::fclose _LIBCPP_USING_IF_EXISTS;
  106. using ::fflush _LIBCPP_USING_IF_EXISTS;
  107. using ::setbuf _LIBCPP_USING_IF_EXISTS;
  108. using ::setvbuf _LIBCPP_USING_IF_EXISTS;
  109. using ::fprintf _LIBCPP_USING_IF_EXISTS;
  110. using ::fscanf _LIBCPP_USING_IF_EXISTS;
  111. using ::snprintf _LIBCPP_USING_IF_EXISTS;
  112. using ::sprintf _LIBCPP_USING_IF_EXISTS;
  113. using ::sscanf _LIBCPP_USING_IF_EXISTS;
  114. using ::vfprintf _LIBCPP_USING_IF_EXISTS;
  115. using ::vfscanf _LIBCPP_USING_IF_EXISTS;
  116. using ::vsscanf _LIBCPP_USING_IF_EXISTS;
  117. using ::vsnprintf _LIBCPP_USING_IF_EXISTS;
  118. using ::vsprintf _LIBCPP_USING_IF_EXISTS;
  119. using ::fgetc _LIBCPP_USING_IF_EXISTS;
  120. using ::fgets _LIBCPP_USING_IF_EXISTS;
  121. using ::fputc _LIBCPP_USING_IF_EXISTS;
  122. using ::fputs _LIBCPP_USING_IF_EXISTS;
  123. using ::getc _LIBCPP_USING_IF_EXISTS;
  124. using ::putc _LIBCPP_USING_IF_EXISTS;
  125. using ::ungetc _LIBCPP_USING_IF_EXISTS;
  126. using ::fread _LIBCPP_USING_IF_EXISTS;
  127. using ::fwrite _LIBCPP_USING_IF_EXISTS;
  128. #ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
  129. using ::fgetpos _LIBCPP_USING_IF_EXISTS;
  130. #endif
  131. using ::fseek _LIBCPP_USING_IF_EXISTS;
  132. #ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
  133. using ::fsetpos _LIBCPP_USING_IF_EXISTS;
  134. #endif
  135. using ::ftell _LIBCPP_USING_IF_EXISTS;
  136. using ::rewind _LIBCPP_USING_IF_EXISTS;
  137. using ::clearerr _LIBCPP_USING_IF_EXISTS;
  138. using ::feof _LIBCPP_USING_IF_EXISTS;
  139. using ::ferror _LIBCPP_USING_IF_EXISTS;
  140. using ::perror _LIBCPP_USING_IF_EXISTS;
  141. using ::fopen _LIBCPP_USING_IF_EXISTS;
  142. using ::freopen _LIBCPP_USING_IF_EXISTS;
  143. using ::remove _LIBCPP_USING_IF_EXISTS;
  144. using ::rename _LIBCPP_USING_IF_EXISTS;
  145. using ::tmpfile _LIBCPP_USING_IF_EXISTS;
  146. using ::tmpnam _LIBCPP_USING_IF_EXISTS;
  147. using ::getchar _LIBCPP_USING_IF_EXISTS;
  148. #if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS)
  149. using ::gets _LIBCPP_USING_IF_EXISTS;
  150. #endif
  151. using ::scanf _LIBCPP_USING_IF_EXISTS;
  152. using ::vscanf _LIBCPP_USING_IF_EXISTS;
  153. using ::printf _LIBCPP_USING_IF_EXISTS;
  154. using ::putchar _LIBCPP_USING_IF_EXISTS;
  155. using ::puts _LIBCPP_USING_IF_EXISTS;
  156. using ::vprintf _LIBCPP_USING_IF_EXISTS;
  157. _LIBCPP_END_NAMESPACE_STD
  158. #endif // _LIBCPP_CSTDIO