RE: [GD-General] Feedback wanted on POSH
Brought to you by:
vexxed72
From: Crosbie F. <cr...@cy...> - 2003-11-19 11:21:44
|
There are two requirements for types I reckon: 1) Size determined requirements with type 2) Policy determined requirements with type So there are things like "I'm developing a data structure with a need for 8 bits of unsigned integer" AND "I need the most efficient data type for expressing a boolean state" or "Best for representing a textual character" or "Compile time choice of floating point number, tradeoff size vs precision vs performance" So there are the sized types: typedef signed __int8 int8; // signed 8 bit integer typedef signed __int16 int16; // signed 16 bit integer typedef signed __int32 int32; // signed 32 bit integer typedef signed __int64 int64; // signed 64 bit integer typedef unsigned __int8 uint8; // unsigned 8 bit integer typedef unsigned __int16 uint16; // unsigned 16 bit integer typedef unsigned __int32 uint32; // unsigned 32 bit integer typedef unsigned __int64 uint64; // unsigned 64 bit integer typedef float float32; // 32 bit floating point typedef double float64; // 64 bit floating point typedef uint8 char_utf8; // 8 bit Unicode char UTF-8 typedef uint16 char_utf16; // 16 bit Unicode UTF-16 etc. typedef uint8 char_ascii; // NB not char in order to maintain consistent signing typedef uint16 char_ucs2; // 16 bit unicode UCS-2 etc. typedef uint8 void8; // Does this make sense? Don't care what type, but I need 8 bits And perhaps other sized types. Note I have used names that should be as obvious as possible to uninformed readers. Hackers can always typedef uint64 as u8 or something (unsigned int where sizeof=8 ). The policy determined types would be things like this: typedef int integer; // If you need an unsized integer use this, also needs range info typedef double real; // If you need an unsized floating point number use this, etc. typedef char_utf8 character; // unsized textual character, etc. typedef bool boolean; |