can someone explain the difference between the types uint8_t
and __u8
?
i know that uint8_t
are defined in stdint.h and they are available on every unix system.
/* Unsigned. */
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
...
And if i use them its recognizable what i intent to do.
now i stumbled over the __u8
and __u16
types. its seems for me to be the same.
some of those types are defined in linux/types.h
#ifdef __CHECKER__
#define __bitwise__ __attribute__((bitwise))
#else
#define __bitwise__
#endif
#ifdef __CHECK_ENDIAN__
#define __bitwise __bitwise__
#else
#define __bitwise
#endif
typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __le32;
...
i didnt find __u8
but i can still use it and it behaves like uint8_t.
is there some difference in performance or memory consumption?
thanks for help :)
A UINT8 is an 8-bit unsigned integer (range: 0 through 255 decimal).
The difference between Uint8 and uint8_t will depend on implementation, but usually they will both be 8 bit unsigned integers. Also uint8_t and uint16_t are defined by C (and maybe C++) standard in stdint. h header, Uint8 and Uint16 are non-standard as far as I know.
u8 : The 8-bit unsigned integer type. u16 : The 16-bit unsigned integer type. u32 : The 32-bit unsigned integer type. u64 : The 64-bit unsigned integer type.
__u32 undeclaredexcept for the problem of too many layers of indirection.
uintn_t
are typedefs specified* by C99 (in <stdint.h>
) and C++11 (in <cstdint>
) standards. All new compilers provide these and appopriate definition is easy to get for the few ancient ones easily, so for portability always use this.
__un
are Linux-specific typedefs predating those standards. They are not portable. The double underscore is used to signify a non-standard definition.
* For 8, 16, 32 and 64 they shall be defined if the compiler has a type of that size, additional ones may be defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With