Pol  Revision:f37d500
rawtypes.h
Go to the documentation of this file.
1 
12 #ifndef __CLIB_RAWTYPES_H
13 #define __CLIB_RAWTYPES_H
14 
15 #define __PACKED__
16 
17 /* The PACK_NEEDED define goes after "struct { }" definitions */
18 #ifdef __GNUC__
19 #define POSTSTRUCT_PACK __attribute__( ( __packed__ ) )
20 #else
21 #define POSTSTRUCT_PACK
22 #endif
23 
24 
25 typedef unsigned char u8;
26 typedef unsigned short u16;
27 typedef unsigned int u32;
28 
29 typedef signed char s8;
30 typedef signed short s16;
31 typedef signed int s32;
32 
33 #ifdef _WIN32
34 typedef unsigned __int64 u64;
35 typedef signed __int64 s64;
36 #define OUT64 "I64"
37 #else
38 typedef unsigned long long u64;
39 typedef signed long long s64;
40 #define OUT64 "ll"
41 #endif
42 
43 
44 /* these fail to compile if lengths of U8, U16, or U32 are incorrect. */
45 static_assert( sizeof( u8 ) == 1, "size missmatch" );
46 static_assert( sizeof( u16 ) == 2, "size missmatch" );
47 static_assert( sizeof( u32 ) == 4, "size missmatch" );
48 static_assert( sizeof( u64 ) == 8, "size missmatch" );
49 static_assert( sizeof( s8 ) == 1, "size missmatch" );
50 static_assert( sizeof( s16 ) == 2, "size missmatch" );
51 static_assert( sizeof( s32 ) == 4, "size missmatch" );
52 static_assert( sizeof( s64 ) == 8, "size missmatch" );
53 
54 // here's where Win32 land and Linux land differ:
55 #ifdef __cplusplus
56 
57 #if defined( _WIN32 )
58 static_assert( sizeof( wchar_t ) == 2, "size missmatch" );
59 #elif defined( __GNUC__ )
60 static_assert( sizeof( wchar_t ) == 4, "size missmatch" );
61 #else
62 #error unknown size for wchar_t
63 #endif
64 
65 #endif
66 
67 #endif /* __STYPE_H */
unsigned char u8
Definition: rawtypes.h:25
unsigned short u16
Definition: rawtypes.h:26
unsigned int u32
Definition: rawtypes.h:27
unsigned long long u64
Definition: rawtypes.h:38
signed short s16
Definition: rawtypes.h:30
signed long long s64
Definition: rawtypes.h:39
signed int s32
Definition: rawtypes.h:31
signed char s8
Definition: rawtypes.h:29