C ++ 11 types of uint vs u_int

I just came across a type u_int8_tbecause it did not compile on Windows + MinGW (but compiled on Linux). According to this site , the C ++ 11 standard defines type uint8_t. I just used the latter and it worked.

The following questions arise:

  • Is there any difference between u_int8_tand uint8_t?
  • Is there a reason (besides legacy code) to use u_int8_t?
  • Can I assume what uint8_twill be present if I use the C ++ 11 compiler (on different OS or architectures)?
  • Answers to the above questions also apply to other types of ( intX_tand uintX_t)?
+4
source share
1 answer

Is there any difference between u_int8_tand uint8_t?

u_int8_t- This is just an old name that has not been standardized. Avoid this.

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

Suicide by a colleague.

Can I assume what uint8_twill be present if I use the C ++ 11 compiler (on different OS or architectures)?

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

Are the answers to the above questions are valid for other types of ( intX_tand uintX_t)?

To a large extent, yes.

+9
source

Source: https://habr.com/ru/post/1538049/


All Articles