delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/01/08/13:30:14

Message-ID: <004d01c079a0$fd2284c0$d497883e@oemcomputer>
From: "Stephen Silver" <djgpp AT argentum DOT freeserve DOT co DOT uk>
To: <djgpp-workers AT delorie DOT com>
Subject: namespace std - stdio.h patch
Date: Mon, 8 Jan 2001 18:29:49 -0000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp-workers AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019