用C固定宽度的整数++ [英] Fixed-width integers in C++
问题描述
我偶尔需要使用固定宽度的整数与PLC的一样外部设备通信。我还用它们来定义位掩码和执行图像数据的位操作。 AFAIK C99标准定义了像int16_t固定宽度的整数。然而,编译器我用,VC ++ 2008不支持C99和AFAIK微软不打算支持它。
Occasionally I need to use fixed-width integers for communication with external devices like PLCs. I also use them to define bitmasks and perform bit manipulation of image data. AFAIK the C99 standard defines fixed-width integers like int16_t. However the compiler I use, VC++ 2008 doesn't support C99 and AFAIK Microsoft is not planning to support it.
我的问题是什么是在C ++中使用固定宽度的整数的最佳做法是什么?
My question is what is the best practice for using fixed-width integers in C++?
我知道VC ++定义像__int16非标准固定宽度的整数,但我很犹豫使用一个非标准的类型。请问下C ++标准限定了固定宽度的整数?
I know that VC++ defines non-standard fixed-width integers like __int16, but I am hesitant to use a non-standard type. Will the next C++ standard define fixed-width integers?
推荐答案
升压拥有了所有类型的C99多的类型定义:
助推整数库
Boost has the typedefs for all of the C99 types and more: "Boost integer library"
这篇关于用C固定宽度的整数++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!