6

I just stumbled upon the type u_int8_t because it did not compile in Windows+MinGW (but compiled fine under Linux). According to this site the C++11 standard defines the type uint8_t. I just used the latter and everything worked.

The questions that arised are:

  1. Is there any difference between u_int8_t and uint8_t?
  2. Is there a reason (besides legacy code) to use u_int8_t?
  3. Is it safe to assume that uint8_t will be present if I use a C++11 compiler (on different OS or architectures)?
  4. Are the answers to the above questions also valid for the other types (intX_t and uintX_t)?
masgo
  • 410
  • 3
  • 14
  • possible duplicate of [ vs ](http://stackoverflow.com/questions/13642827/cstdint-vs-stdint-h) – Klaus Apr 25 '14 at 11:40
  • No. The question you mention deals with the difference between `cstdint` and `stdint.h`. The type `u_int8_t` is defined in `sys/types.h`. But this header is usually not available in Windows and/or MinGW. – masgo Apr 25 '14 at 12:28

1 Answers1

12

Is there any difference between u_int8_t and uint8_t?

u_int8_t is just a very old name that was not standardised. Avoid it.

Is there a reason (besides legacy code) to use u_int8_t?

Suicide by coworker.

Is it safe to assume that uint8_t will be present if I use a C++11 compiler (on different OS or architectures)?

The C++ standard requires it to be present on all implementations that have an unsigned 8-bit type available (today that means everything that is not exotic).

Are the answers to the above questions also valid for the other types (intX_t and uintX_t)?

Pretty much, yes.

R. Martinho Fernandes
  • 209,766
  • 68
  • 412
  • 492