www.digitalmars.com         C & C++   DMDScript  

c++.rtl - header problems

reply Linus <linus linus.cx> writes:
Dear Walter,
thank you for your helpful hint regarding the 'findfirst' problem. It
fits my needs very well.
Thank you also very much for continuing your great work on the compiler.
But now for the problem.
Compiling some programs that built well with SC6.1 with DM8.23, I got
some error messages related to standard headers.

1. Including <conio.h> and <dos.h> togerther revealed conflicting
declarations for some port i/o functions.

2. When __STDC__ is defined (strict ANSI mode), in <stdlib.h> and
<string.h> definitions for _CLIB and wchar_t respectively are
conditionally ignored, leading to errors in the subsequent processing of
the headers. 

My solution to the problem was to modify the headers (see appended
diff)  although I'm not shure this is the optimum solution as I can't
figure out why the conditionals were put there in the first place (but
have seen the same commenting-out at least in one other place in
<stdlib.h>).
Yes, I admit to have broken the golden rule to never ever touch
compiler/system headers! But I swear I had to ... well at least I didn't
want to do much more ugly things.

With best regards
Linus


diff -B -w -c old/conio.h conio.h
*** old/conio.h	Fri Mar 16 23:15:22 2001
--- conio.h	Sat Nov 17 17:42:18 2001
***************
*** 280,288 ****
  #else /* M_UNIX || M_XENIX */

  unsigned char	__cdecl inp(unsigned);
! unsigned char	__cdecl outp(unsigned,char);
! int		__cdecl inpw(unsigned);
! int		__cdecl outpw(unsigned,unsigned);

  #endif  /* M_UNIX || M_XENIX */

--- 280,288 ----
  #else /* M_UNIX || M_XENIX */

  unsigned char	__cdecl inp(unsigned);
! unsigned char	__cdecl outp(unsigned,unsigned char);
! unsigned short	__cdecl inpw(unsigned);
! unsigned short	__cdecl outpw(unsigned,unsigned short);

  #endif  /* M_UNIX || M_XENIX */

***************
*** 313,321 ****

  /* For inline code generation for inp(), inpw(), outp() and outpw()
functions */
  unsigned char	__CLIB _inline_inp(unsigned);
! int		__CLIB _inline_inpw(unsigned);
! unsigned char	__CLIB _inline_outp(unsigned,char);
! int		__CLIB _inline_outpw(unsigned,unsigned);

  #define inp(x)		_inline_inp(x)
  #define inpw(x)		_inline_inpw(x)
--- 313,321 ----

  /* For inline code generation for inp(), inpw(), outp() and outpw()
functions */
  unsigned char	__CLIB _inline_inp(unsigned);
! unsigned short	__CLIB _inline_inpw(unsigned);
! unsigned char	__CLIB _inline_outp(unsigned,unsigned char);
! unsigned short	__CLIB _inline_outpw(unsigned,unsigned short);

  #define inp(x)		_inline_inp(x)
  #define inpw(x)		_inline_inpw(x)
diff -B -w -c old/stdlib.h stdlib.h
*** old/stdlib.h	Sun Sep 30 01:34:54 2001
--- stdlib.h	Sat Nov 17 19:07:28 2001
***************
*** 57,63 ****
  #endif
  #pragma pack()

! #if !__STDC__

  #if !defined(ERANGE)
  #define ERANGE 34
--- 57,63 ----
  #endif
  #pragma pack()

! //#if !__STDC__

  #if !defined(ERANGE)
  #define ERANGE 34
***************
*** 83,89 ****
  #define MB_CUR_MAX	1
  #endif

! #endif

  #define _MAX_PATH   260
  #define _MAX_DRIVE  3
--- 83,89 ----
  #define MB_CUR_MAX	1
  #endif

! //#endif

  #define _MAX_PATH   260
  #define _MAX_DRIVE  3
diff -B -w -c old/string.h string.h
*** old/string.h	Tue Oct  9 23:29:18 2001
--- string.h	Sat Nov 17 04:01:18 2001
***************
*** 33,44 ****

  typedef unsigned size_t;

! #ifndef __STDC__
  #if !defined(_WCHAR_T_DEFINED)
  typedef unsigned short wchar_t;
  #define _WCHAR_T_DEFINED 1
  #endif
! #endif

  #define _NLSCMPERROR	2147483647

--- 33,44 ----

  typedef unsigned size_t;

! //#ifndef __STDC__
  #if !defined(_WCHAR_T_DEFINED)
  typedef unsigned short wchar_t;
  #define _WCHAR_T_DEFINED 1
  #endif
! //#endif

  #define _NLSCMPERROR	2147483647
Nov 28 2001
parent "Walter" <walter digitalmars.com> writes:
thanks!

"Linus" <linus linus.cx> wrote in message news:3C0596AA.6796 linus.cx...
 Dear Walter,
 thank you for your helpful hint regarding the 'findfirst' problem. It
 fits my needs very well.
 Thank you also very much for continuing your great work on the compiler.
 But now for the problem.
 Compiling some programs that built well with SC6.1 with DM8.23, I got
 some error messages related to standard headers.

 1. Including <conio.h> and <dos.h> togerther revealed conflicting
 declarations for some port i/o functions.

 2. When __STDC__ is defined (strict ANSI mode), in <stdlib.h> and
 <string.h> definitions for _CLIB and wchar_t respectively are
 conditionally ignored, leading to errors in the subsequent processing of
 the headers.

 My solution to the problem was to modify the headers (see appended
 diff)  although I'm not shure this is the optimum solution as I can't
 figure out why the conditionals were put there in the first place (but
 have seen the same commenting-out at least in one other place in
 <stdlib.h>).
 Yes, I admit to have broken the golden rule to never ever touch
 compiler/system headers! But I swear I had to ... well at least I didn't
 want to do much more ugly things.

 With best regards
 Linus


 diff -B -w -c old/conio.h conio.h
 *** old/conio.h Fri Mar 16 23:15:22 2001
 --- conio.h Sat Nov 17 17:42:18 2001
 ***************
 *** 280,288 ****
   #else /* M_UNIX || M_XENIX */

   unsigned char __cdecl inp(unsigned);
 ! unsigned char __cdecl outp(unsigned,char);
 ! int __cdecl inpw(unsigned);
 ! int __cdecl outpw(unsigned,unsigned);

   #endif  /* M_UNIX || M_XENIX */

 --- 280,288 ----
   #else /* M_UNIX || M_XENIX */

   unsigned char __cdecl inp(unsigned);
 ! unsigned char __cdecl outp(unsigned,unsigned char);
 ! unsigned short __cdecl inpw(unsigned);
 ! unsigned short __cdecl outpw(unsigned,unsigned short);

   #endif  /* M_UNIX || M_XENIX */

 ***************
 *** 313,321 ****

   /* For inline code generation for inp(), inpw(), outp() and outpw()
 functions */
   unsigned char __CLIB _inline_inp(unsigned);
 ! int __CLIB _inline_inpw(unsigned);
 ! unsigned char __CLIB _inline_outp(unsigned,char);
 ! int __CLIB _inline_outpw(unsigned,unsigned);

   #define inp(x) _inline_inp(x)
   #define inpw(x) _inline_inpw(x)
 --- 313,321 ----

   /* For inline code generation for inp(), inpw(), outp() and outpw()
 functions */
   unsigned char __CLIB _inline_inp(unsigned);
 ! unsigned short __CLIB _inline_inpw(unsigned);
 ! unsigned char __CLIB _inline_outp(unsigned,unsigned char);
 ! unsigned short __CLIB _inline_outpw(unsigned,unsigned short);

   #define inp(x) _inline_inp(x)
   #define inpw(x) _inline_inpw(x)
 diff -B -w -c old/stdlib.h stdlib.h
 *** old/stdlib.h Sun Sep 30 01:34:54 2001
 --- stdlib.h Sat Nov 17 19:07:28 2001
 ***************
 *** 57,63 ****
   #endif
   #pragma pack()

 ! #if !__STDC__

   #if !defined(ERANGE)
   #define ERANGE 34
 --- 57,63 ----
   #endif
   #pragma pack()

 ! file://#if !__STDC__

   #if !defined(ERANGE)
   #define ERANGE 34
 ***************
 *** 83,89 ****
   #define MB_CUR_MAX 1
   #endif

 ! #endif

   #define _MAX_PATH   260
   #define _MAX_DRIVE  3
 --- 83,89 ----
   #define MB_CUR_MAX 1
   #endif

 ! file://#endif

   #define _MAX_PATH   260
   #define _MAX_DRIVE  3
 diff -B -w -c old/string.h string.h
 *** old/string.h Tue Oct  9 23:29:18 2001
 --- string.h Sat Nov 17 04:01:18 2001
 ***************
 *** 33,44 ****

   typedef unsigned size_t;

 ! #ifndef __STDC__
   #if !defined(_WCHAR_T_DEFINED)
   typedef unsigned short wchar_t;
   #define _WCHAR_T_DEFINED 1
   #endif
 ! #endif

   #define _NLSCMPERROR 2147483647

 --- 33,44 ----

   typedef unsigned size_t;

 ! file://#ifndef __STDC__
   #if !defined(_WCHAR_T_DEFINED)
   typedef unsigned short wchar_t;
   #define _WCHAR_T_DEFINED 1
   #endif
 ! file://#endif

   #define _NLSCMPERROR 2147483647
Nov 29 2001