www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 450] New: frontend: please use <stdint.h> to increase portability

http://d.puremagic.com/issues/show_bug.cgi?id=450

           Summary: frontend: please use <stdint.h> to increase portability
           Product: D
           Version: 0.170
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: patch
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thomas-dloop kuehne.cn


The patch below takes care of defining the d_<integer> types in a portable way.

=== dmd/mars.h
==================================================================
--- dmd/mars.h  (revision 2010)
+++ dmd/mars.h  (local)
   -138,21 +138,23   
  #endif
 #endif

+#include <stdint.h>
+
 // Be careful not to care about sign with integer_t
-typedef unsigned long long integer_t;
+typedef uint64_t integer_t;

 // Signed and unsigned variants
-typedef long long sinteger_t;
-typedef unsigned long long uinteger_t;
+typedef int64_t  sinteger_t;
+typedef uint64_t uinteger_t;

-typedef signed char            d_int8;
-typedef unsigned char          d_uns8;
-typedef short                  d_int16;
-typedef unsigned short         d_uns16;
-typedef int                    d_int32;
-typedef unsigned               d_uns32;
-typedef long long              d_int64;
-typedef unsigned long long     d_uns64;
+typedef int8_t                 d_int8;
+typedef uint8_t                        d_uns8;
+typedef int16_t                        d_int16;
+typedef uint16_t               d_uns16;
+typedef int32_t                        d_int32;
+typedef uint32_t               d_uns32;
+typedef int64_t                        d_int64;
+typedef uint64_t               d_uns64;

 typedef float                  d_float32;
 typedef double                 d_float64;


-- 
Oct 24 2006