C ++中的跨平台原始数据类型 [英] Cross-platform primitive data types in C++

查看:271
本文介绍了C ++中的跨平台原始数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与Java或C#不同,C ++中的原始数据类型的大小会因平台而异。例如, int 不能保证是一个32位整数。
各种编译器环境为此目的定义数据类型,例如 uint32 dword ,但似乎有没有固定大小数据类型的标准包含文件。

Unlike Java or C#, primitive data types in C++ can vary in size depending on the platform. For example, int is not guaranteed to be a 32-bit integer. Various compiler environments define data types such as uint32 or dword for this purpose, but there seems to be no standard include file for fixed-size data types.

实现最大可移植性的推荐方法是什么?

What is the recommended method to achieve maximum portability?

推荐答案

我发现这个标题特别有用:
BOOST cstdint

I found this header particularly useful: BOOST cstdint

通常比发明自己的轮子更好维护和测试)。

Usually better than inventing own wheel (which incurs the maintenance and testing).

这篇关于C ++中的跨平台原始数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆