Mail Archives: djgpp-workers/2001/01/08/13:30:14
At the end of this message is the namespace std patch for stdio.h.
This is a little more complicated than I showed in the outline in my
message yesterday, because certain variables need to be hoisted regardless
of whether __dj_via_cplusplus_header_ is true, otherwise stdin, stdout,
etc., won't work.
With this patch, the first four programs in my "namespace std - examples"
message all compile and run even with -fhonor-std. In order to prevent
the incorrect one from compiling it is necessary also to change
lang/cxx/cstdio to:
#define __dj_via_cplusplus_header_
#include <stdio.h>
#undef __dj_via_cplusplus_header_
Is this patch acceptable? If not, then I need to know what the problems
are before I go ahead and do the same thing with every other standard C
header file.
Stephen
*** include/stdio.h.old Tue Dec 5 14:05:54 2000
--- include/stdio.h Mon Jan 8 18:08:26 2001
***************
*** 6,9 ****
--- 6,10 ----
#ifdef __cplusplus
+ namespace std {
extern "C" {
#endif
***************
*** 152,156 ****
--- 153,249 ----
#ifdef __cplusplus
}
+ }
#endif
#endif /* !__dj_include_stdio_h_ */
+
+
+ #if defined(__cplusplus) && !defined(__dj_ENFORCE_ANSI_FREESTANDING)
+
+ using std::__dj_stdin;
+ using std::__dj_stdout;
+ using std::__dj_stderr;
+
+ #if !defined(__STRICT_ANSI__) && !defined(_POSIX_SOURCE)
+ using std::__dj_stdprn;
+ using std::__dj_stdaux;
+ #endif
+
+ #ifndef __dj_via_cplusplus_header_
+
+ using std::FILE;
+ using std::fpos_t;
+ using std::size_t;
+
+ using std::clearerr;
+ using std::fclose;
+ using std::feof;
+ using std::ferror;
+ using std::fflush;
+ using std::fgetc;
+ using std::fgetpos;
+ using std::fgets;
+ using std::fopen;
+ using std::fprintf;
+ using std::fputc;
+ using std::fputs;
+ using std::fread;
+ using std::freopen;
+ using std::fscanf;
+ using std::fseek;
+ using std::fsetpos;
+ using std::ftell;
+ using std::fwrite;
+ using std::getc;
+ using std::getchar;
+ using std::gets;
+ using std::perror;
+ using std::printf;
+ using std::putc;
+ using std::putchar;
+ using std::puts;
+ using std::remove;
+ using std::rename;
+ using std::rewind;
+ using std::scanf;
+ using std::setbuf;
+ using std::setvbuf;
+ using std::sprintf;
+ using std::sscanf;
+ using std::tmpfile;
+ using std::tmpnam;
+ using std::ungetc;
+ using std::vfprintf;
+ using std::vprintf;
+ using std::vsprintf;
+
+ #ifndef __STRICT_ANSI__
+
+ using std::fileno;
+ using std::fdopen;
+ using std::pclose;
+ using std::popen;
+
+ #ifndef _POSIX_SOURCE
+
+ using std::_djstat_describe_lossage;
+ using std::_doprnt;
+ using std::_doscan;
+ using std::_doscan_low;
+ using std::fpurge;
+ using std::getw;
+ using std::mkstemp;
+ using std::mktemp;
+ using std::putw;
+ using std::setbuffer;
+ using std::setlinebuf;
+ using std::tempnam;
+ using std::_rename;
+ using std::vfscanf;
+ using std::vscanf;
+ using std::vsscanf;
+
+ #endif /* !_POSIX_SOURCE */
+ #endif /* !__STRICT_ANSI__ */
+ #endif /* !__dj_via_cplusplus_header_ */
+ #endif /* __cplusplus && !__dj_ENFORCE_ANSI_FREESTANDING */
- Raw text -