C++ (Qt)namespace std {typedef signed integer type int8_t; // optionaltypedef signed integer type int16_t; // optionaltypedef signed integer type int32_t; // optionaltypedef signed integer type int64_t; // optionaltypedef signed integer type int_fast8_t;typedef signed integer type int_fast16_t;typedef signed integer type int_fast32_t;typedef signed integer type int_fast64_t;typedef signed integer type int_least8_t;typedef signed integer type int_least16_t;typedef signed integer type int_least32_t;typedef signed integer type int_least64_t;typedef signed integer type intmax_t;typedef signed integer type intptr_t; // optionaltypedef unsigned integer type uint8_t; // optionaltypedef unsigned integer type uint16_t; // optionaltypedef unsigned integer type uint32_t; // optionaltypedef unsigned integer type uint64_t; // optionaltypedef unsigned integer type uint_fast8_t;typedef unsigned integer type uint_fast16_t;typedef unsigned integer type uint_fast32_t;typedef unsigned integer type uint_fast64_t;typedef unsigned integer type uint_least8_t;typedef unsigned integer type uint_least16_t;typedef unsigned integer type uint_least32_t;typedef unsigned integer type uint_least64_t;typedef unsigned integer type uintmax_t;typedef unsigned integer type uintptr_t; // optional} // namespace std
short x = 0x00A3;char y[12];y[8] = ?; y[9] = ?;
C++ (Qt)y[8] = x & 127; // lowery[9] = x >> 7; // upper
C++ (Qt)union Arr { char y_char[12]; short y_short[6];};inline short MkShort( int lo, int hi ) { return short((hi << 8) | lo); }..Arr myArr;...myArr.y_short[4] = some_value; // илиmyArr.y_short[4] = MkShort(0, 0xA3);
Cvoud testEndianMachine(){ union // Used for endian check, defines big endian layout { short int16Word; struct { char high; char low; } bytes; }; union // Used for float endian check, defines big endian layout { float float32Value; struct { unsigned int sign : 1; unsigned int exponent: 8; unsigned int fraction0: 7; unsigned int fraction1: 16; } number; }; int16Word = 0x1234; // Magic value to detect endianess float32Value = -1.0; // Magic value to detect endianess // // Endian check for integer words // if (bytes.high == 0x34) // Little endian { bigEndianMachine = 0; } else // Big endian { bigEndianMachine = 1; } // // Endian check for floats // if (number.sign) // Big endian { bigEndianFloatMachine = 1; } else // Little endian { bigEndianFloatMachine = 0; }}