本文介绍了定义标准类型的最佳多平台方式,如UINT32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写将在多个Windows和多个* nix

平台上编译的代码。有些人会有64位整数,我相信。


定义与平台无关的类型(如UINT32

或UINT64)的最佳选择是什么?我不知道如何整理各种平台和整数

大小,其中一些甚至可能因编译器选项而异。


谢谢

-

David T. Ashley(dt *@e3ft.com)
(咨询主页)
(个人主页)
(GPL出版物和项目)

I''m writing code which will compile on multiple Windows and multiple *nix
platforms. Some will have 64-bit integers, I believe.

What is my best option to define platform-independent types such as UINT32
or UINT64? I''m not sure how to sort out the various platforms and integer
sizes, and some of it may even vary based on compiler options.

Thanks
--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)

推荐答案



启动的好地方可能是< stdint.hon 64位支持b $ b的系统之一。我认为你应该使用标准类型,而不是

重新定义它们。


-

Ian Collins。

Probably a good place to start would be <stdint.hon one of the 64 bit
capable systems. I think you should use the standard types, rather than
redefining them in caps.

--
Ian Collins.




启动的好地方可能是< stdint.hon 64位支持b $ b的系统之一。我认为你应该使用标准类型,而不是

重新定义它们。

Probably a good place to start would be <stdint.hon one of the 64 bit
capable systems. I think you should use the standard types, rather than
redefining them in caps.



感谢您提供的信息。我在我的Linux机器上查找了这个文件(< stdint.h>),

,这正是我想要的。


但是,我也有Microsoft Visual C ++。我无法找到< stdint.hin

包含目录,所以为了确保我没有遗漏一些东西,我在搜索微软的'b $ b'网站stdint.h没有匹配。


我认为Microsoft工具链没有这样的文件。不清楚

做什么,因为即使是Windows也会在64位平台上运行。


建议?


Dave。

-

David T. Ashley(dt *@e3ft.com)
(咨询主页)
(个人主页)
(GPL出版物和项目)

Thanks for that info. I looked up this file (<stdint.h>) on my Linux box,
and it is just what I was looking for.

However, I also have Microsoft Visual C++. I couldn''t find <stdint.hin
the include directory, so just to be sure I wasn''t missing something, I
searched Microsoft''s site by "stdint.h" and got no matches.

I think the Microsoft tool chain doesn''t have such a file. It isn''t clear
what to do, because even Windows will run on some 64-bit platforms.

Suggestions?

Dave.
--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)



可能一个好的起点是< stdint.hon 64位
系统之一。我认为你应该使用标准类型,而不是重新定义它们。


Probably a good place to start would be <stdint.hon one of the 64 bit
capable systems. I think you should use the standard types, rather than
redefining them in caps.




感谢您提供的信息。我在我的Linux机器上查找了这个文件(< stdint.h>),

,这正是我想要的。


但是,我也有Microsoft Visual C ++。我无法找到< stdint.hin

包含目录,所以为了确保我没有遗漏一些东西,我在搜索微软的'b $ b'网站stdint.h没有匹配。


我认为Microsoft工具链没有这样的文件。不清楚

做什么,因为即使是Windows也会在64位平台上运行。


建议?


戴夫。



Thanks for that info. I looked up this file (<stdint.h>) on my Linux box,
and it is just what I was looking for.

However, I also have Microsoft Visual C++. I couldn''t find <stdint.hin
the include directory, so just to be sure I wasn''t missing something, I
searched Microsoft''s site by "stdint.h" and got no matches.

I think the Microsoft tool chain doesn''t have such a file. It isn''t clear
what to do, because even Windows will run on some 64-bit platforms.

Suggestions?

Dave.



是的。只需将你的linux stdint.h复制到你的微软安装......


不是很难。 stdint.h是标准C.微软并不总是

遵守它但这很容易理解。


当然你应该记住64位微软环境,

长是32位,64位linux下是64位。该文件最多需要一个小的编辑更改。

Yes. Just copy your linux stdint.h to your Microsoft installation...

NOT very difficult. stdint.h is standard C. Microsoft dpesn''t always
comply with it but this is easy to follow.

Of course you should remember that in 64 bit microsoft environment,
long is 32 bits and under 64 bit linux it is 64 bits. The file would
need at most a small editing change.


这篇关于定义标准类型的最佳多平台方式,如UINT32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 12:54