delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/02/07/18:30:49

Message-ID: <003a01c09158$f39742e0$f9e4883e@oemcomputer>
From: "Stephen Silver" <djgpp AT argentum DOT freeserve DOT co DOT uk>
To: "DJGPP Workers" <djgpp-workers AT delorie DOT com>
Subject: stddef.h - namespace std patch
Date: Wed, 7 Feb 2001 22:54:36 -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

This is the stddef.h patch.

The only complication here is that 'offsetof' needs a different
definition in C++ (using std::size_t instead of size_t).
This could be avoided by taking advantage of the fact that
'size_t' means 'unsigned long', but I assumed that wasn't a
good idea.

Stephen


*** include/stddef.h.old Tue Dec  5 14:05:54 2000
--- include/stddef.h Mon Feb  5 18:31:30 2001
***************
*** 4,7 ****
--- 4,8 ----

  #ifdef __cplusplus
+ namespace std {
  extern "C" {
  #endif
***************
*** 10,14 ****
--- 11,19 ----

  #define NULL 0
+ #ifdef __cplusplus
+ #define offsetof(s_type, mbr) ((std::size_t) &((s_type *)0)->mbr)
+ #else
  #define offsetof(s_type, mbr) ((size_t) &((s_type *)0)->mbr)
+ #endif

  #ifndef _PTRDIFF_T
***************
*** 42,46 ****
--- 47,62 ----
  #ifdef __cplusplus
  }
+ }
  #endif

  #endif /* !__dj_include_stddef_h_ */
+
+
+ #if defined(__cplusplus)
+ #ifndef __dj_via_cplusplus_header_
+
+ using std::ptrdiff_t;
+ using std::size_t;
+
+ #endif /* !__dj_via_cplusplus_header_ */
+ #endif /* __cplusplus */

- Raw text -


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