1- /** 
2-  * D header file for C99. 
1+ /* **
2+  * D compatible types that correspond to various basic types in associated 
3+  * C and C++ compilers. 
34 * 
45 * Copyright: Copyright Sean Kelly 2005 - 2009. 
56 * License: Distributed under the 
1213
1314module  core.stdc.config ;
1415
16+ version  (StdDdoc)
17+ {
18+     /* **
19+      * Used for a signed integer type that corresponds in size to the associated 
20+      * C compiler's `long` type. 
21+      */  
22+     alias  c_long = int ;
23+ 
24+     /* **
25+      * Used for an unsigned integer type that corresponds in size to the associated 
26+      * C compiler's `unsigned long` type. 
27+      */  
28+     alias  c_ulong = uint ;
29+ 
30+     /* **
31+      * Used for a signed integer type that corresponds in size and mangling to the associated 
32+      * C++ compiler's `long` type. 
33+      */  
34+     alias  cpp_long = c_long;
35+ 
36+     /* **
37+      * Used for an unsigned integer type that corresponds in size and mangling to the associated 
38+      * C++ compiler's `unsigned long` type. 
39+      */  
40+     alias  cpp_ulong = c_ulong;
41+ 
42+     /* **
43+      * Used for a floating point type that corresponds in size and mangling to the associated 
44+      * C++ compiler's `long double` type. 
45+      */  
46+     alias  c_long_double = real ;
47+ 
48+     /* **
49+      * Used for an unsigned integer type that corresponds in size and mangling to the associated 
50+      * C++ compiler's `size_t` type. 
51+      */  
52+     alias  cpp_size_t = size_t ;
53+ 
54+     /* **
55+      * Used for a signed integer type that corresponds in size and mangling to the associated 
56+      * C++ compiler's `ptrdiff_t` type. 
57+      */  
58+     alias  cpp_ptrdiff_t = ptrdiff_t ;
59+ }
60+ else 
61+ {
62+ 
1563version  (OSX )
1664    version  = Darwin;
1765else version  (iOS)
@@ -21,40 +69,10 @@ else version (TVOS)
2169else version  (WatchOS)
2270    version  = Darwin;
2371
24- extern  (C ):
25- @trusted : //  Types only.
26- nothrow :
27- @nogc :
28- 
2972version ( Windows  )
3073{
31-     struct  __c_long 
32-     {
33-       pure  nothrow  @nogc  @safe :
34-         this (int  x) { lng = x; }
35-         int  lng;
36-         alias  lng this ;
37-     }
38- 
39-     struct  __c_ulong 
40-     {
41-       pure  nothrow  @nogc  @safe :
42-         this (uint  x) { lng = x; }
43-         uint  lng;
44-         alias  lng this ;
45-     }
46- 
47-     /* 
48-      * This is cpp_long instead of c_long because: 
49-      * 1. Implicit casting of an int to __c_long doesn't happen, because D doesn't 
50-      *    allow constructor calls in implicit conversions. 
51-      * 2. long lng; 
52-      *    cast(__c_long)lng; 
53-      *    does not work because lng has to be implicitly cast to an int in the constructor, 
54-      *    and since that truncates it is not done. 
55-      * Both of these break existing code, so until we find a resolution the types are named 
56-      * cpp_xxxx. 
57-      */  
74+     enum  __c_long  : int ;
75+     enum  __c_ulong : uint ;
5876
5977    alias  __c_long   cpp_long;
6078    alias  __c_ulong  cpp_ulong;
@@ -66,26 +84,19 @@ else version( Posix )
6684{
6785  static  if ( (void * ).sizeof >  int .sizeof )
6886  {
87+     enum  __c_long  : long ;
88+     enum  __c_ulong : ulong ;
89+ 
90+     alias  __c_long   cpp_long;
91+     alias  __c_ulong  cpp_ulong;
92+ 
6993    alias  long   c_long;
7094    alias  ulong  c_ulong;
7195  }
7296  else 
7397  {
74-     struct  __c_long 
75-     {
76-       pure  nothrow  @nogc  @safe :
77-         this (int  x) { lng = x; }
78-         int  lng;
79-         alias  lng this ;
80-     }
81- 
82-     struct  __c_ulong 
83-     {
84-       pure  nothrow  @nogc  @safe :
85-         this (uint  x) { lng = x; }
86-         uint  lng;
87-         alias  lng this ;
88-     }
98+     enum  __c_long  : int ;
99+     enum  __c_ulong : uint ;
89100
90101    alias  __c_long   cpp_long;
91102    alias  __c_ulong  cpp_ulong;
@@ -103,13 +114,7 @@ version( CRuntime_Microsoft )
103114     * to generate the correct name mangling and correct function call/return 
104115     * ABI conformance. 
105116     */  
106-     struct  __c_long_double 
107-     {
108-       pure  nothrow  @nogc  @safe :
109-         this (double  d) { ld = d; }
110-         double  ld;
111-         alias  ld this ;
112-     }
117+     enum  __c_long_double : double ;
113118
114119    alias  __c_long_double c_long_double;
115120}
@@ -150,3 +155,15 @@ else version( SDC )
150155}
151156
152157static  assert (is (c_long_double), " c_long_double needs to be declared for this platform/architecture." 
158+ 
159+ version  (Darwin)
160+ {
161+     alias  cpp_size_t = cpp_ulong;
162+     alias  cpp_ptrdiff_t = cpp_long;
163+ }
164+ else 
165+ {
166+     alias  cpp_size_t = size_t ;
167+     alias  cpp_ptrdiff_t = ptrdiff_t ;
168+ }
169+ }
0 commit comments