libstdc++
cstdio
Go to the documentation of this file.
1 // -*- C++ -*- forwarding header.
2 
3 // Copyright (C) 1997-2025 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /** @file include/cstdio
26  * This is a Standard C++ Library file. You should @c \#include this file
27  * in your programs, rather than any of the @a *.h implementation files.
28  *
29  * This is the C++ version of the Standard C Library header @c stdio.h,
30  * and its contents are (mostly) the same as that header, but are all
31  * contained in the namespace @c std (except for names which are defined
32  * as macros in C).
33  */
34 
35 //
36 // ISO C++ 14882: 27.8.2 C Library files
37 //
38 
39 #ifndef _GLIBCXX_CSTDIO
40 #define _GLIBCXX_CSTDIO 1
41 
42 #ifdef _GLIBCXX_SYSHDR
43 #pragma GCC system_header
44 #endif
45 
46 #include <bits/c++config.h>
47 #include <stdio.h>
48 
49 #if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS)
50 extern "C" char* gets (char* __s) __attribute__((__deprecated__));
51 #endif
52 
53 // Get rid of those macros defined in <stdio.h> in lieu of real functions.
54 #undef clearerr
55 #undef fclose
56 #undef feof
57 #undef ferror
58 #undef fflush
59 #undef fgetc
60 #undef fgetpos
61 #undef fgets
62 #undef fopen
63 #undef fprintf
64 #undef fputc
65 #undef fputs
66 #undef fread
67 #undef freopen
68 #undef fscanf
69 #undef fseek
70 #undef fsetpos
71 #undef ftell
72 #undef fwrite
73 #undef getc
74 #undef getchar
75 #if __cplusplus <= 201103L
76 # undef gets
77 #endif
78 #undef perror
79 #undef printf
80 #undef putc
81 #undef putchar
82 #undef puts
83 #undef remove
84 #undef rename
85 #undef rewind
86 #undef scanf
87 #undef setbuf
88 #undef setvbuf
89 #undef sprintf
90 #undef sscanf
91 #undef tmpfile
92 #undef tmpnam
93 #undef ungetc
94 #undef vfprintf
95 #undef vprintf
96 #undef vsprintf
97 
98 namespace std
99 {
100  using ::FILE;
101  using ::fpos_t;
102 
103  using ::clearerr;
104  using ::fclose;
105  using ::feof;
106  using ::ferror;
107  using ::fflush;
108  using ::fgetc;
109  using ::fgetpos;
110  using ::fgets;
111  using ::fopen;
112  using ::fprintf;
113  using ::fputc;
114  using ::fputs;
115  using ::fread;
116  using ::freopen;
117  using ::fscanf;
118  using ::fseek;
119  using ::fsetpos;
120  using ::ftell;
121  using ::fwrite;
122  using ::getc;
123  using ::getchar;
124 #if __cplusplus <= 201103L
125  // LWG 2249
126  using ::gets;
127 #endif
128  using ::perror;
129  using ::printf;
130  using ::putc;
131  using ::putchar;
132  using ::puts;
133  using ::remove;
134  using ::rename;
135  using ::rewind;
136  using ::scanf;
137  using ::setbuf;
138  using ::setvbuf;
139  using ::sprintf;
140  using ::sscanf;
141  using ::tmpfile;
142 #if _GLIBCXX_USE_TMPNAM
143  using ::tmpnam;
144 #endif
145  using ::ungetc;
146  using ::vfprintf;
147  using ::vprintf;
148  using ::vsprintf;
149 } // namespace
150 
151 #if _GLIBCXX_USE_C99_STDIO
152 
153 #undef snprintf
154 #undef vfscanf
155 #undef vscanf
156 #undef vsnprintf
157 #undef vsscanf
158 
159 namespace __gnu_cxx
160 {
161 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
162  extern "C" int
163  (snprintf)(char * __restrict, std::size_t, const char * __restrict, ...)
164  throw ();
165  extern "C" int
166  (vfscanf)(FILE * __restrict, const char * __restrict, __gnuc_va_list);
167  extern "C" int (vscanf)(const char * __restrict, __gnuc_va_list);
168  extern "C" int
169  (vsnprintf)(char * __restrict, std::size_t, const char * __restrict,
170  __gnuc_va_list) throw ();
171  extern "C" int
172  (vsscanf)(const char * __restrict, const char * __restrict, __gnuc_va_list)
173  throw ();
174 #endif
175 
176 #if !_GLIBCXX_USE_C99_DYNAMIC
177  using ::snprintf;
178  using ::vfscanf;
179  using ::vscanf;
180  using ::vsnprintf;
181  using ::vsscanf;
182 #endif
183 } // namespace __gnu_cxx
184 
185 namespace std
186 {
187  using ::__gnu_cxx::snprintf;
188  using ::__gnu_cxx::vfscanf;
189  using ::__gnu_cxx::vscanf;
190  using ::__gnu_cxx::vsnprintf;
191  using ::__gnu_cxx::vsscanf;
192 } // namespace std
193 
194 #endif // _GLIBCXX_USE_C99_STDIO
195 
196 #endif