什么是缓冲区的memcpy / memset的等能够处理的最大尺寸是多少? [英] What is the maximum size of buffers memcpy/memset etc. can handle?

查看:651
本文介绍了什么是缓冲区的memcpy / memset的等能够处理的最大尺寸是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是缓冲区 memcpy和可以处理等功能的最大尺寸是多少?这是实现相关的?这是通过限制大小(为size_t)传递作为参数?

What is the maximum size of buffers memcpy and other functions can handle? Is this implementation dependent? Is this restricted by the size(size_t) passed in as an argument?

推荐答案

这完全依赖于实现。

此取决于硬件多达什么,而且还对编译的年龄。对于一个比较现代的编译器(意思是基于从90年代初或更高标准的任何东西)的人,尺寸参数是一个为size_t 。这可以合理地成为最大的16位无符号,最大的32位无符号,或最大的64位无符号,根据不同的内存模型编译器编译到。在这种情况下,你只需要找出大小为size_t 是您的实现。然而,对于非常旧的编译器(即ANSI-C之前的也许ANSI C 的一些早期版本),所有的赌注都关闭。

This depends on the hardware as much as anything, but also on the age of the compiler. For anyone with a reasonably modern compiler (meaning anything based on a standard from the early 90's or later), the size argument is a size_t. This can reasonably be the largest 16 bit unsigned, the largest 32 bit unsigned, or the largest 64 bit unsigned, depending on the memory model the compiler compiles to. In this case, you just have to find out what size a size_t is in your implementation. However, for very old compilers (that is, before ANSI-C and perhaps for some early versions of ANSI C), all bets are off.

在标准方面,在看的cygwin和Solaris 7,例如,尺寸参数是一个为size_t 。看着一个嵌入式系统,我有可用的,尺寸参数是无符号(即16位无符号)。 (此嵌入式系统的编译器写于上世纪80年代)。我发现了一个Web引用一些ANSI C的该尺寸参数是 INT

On the standards side, looking at cygwin and Solaris 7, for example, the size argument is a size_t. Looking at an embedded system that I have available, the size argument is an unsigned (meaning 16-bit unsigned). (The compiler for this embedded system was written in the 80's.) I found a web reference to some ANSI C where the size parameter is an int.

您可能希望看到为size_t >还有后续的一些早期版本的GCC的错误专题文章其中为size_t 被错误地签署。

You may want to see this article on size_t as well as the follow-up article about a mis-feature of some early GCC versions where size_t was erroneously signed.

总之,的几乎每个人为size_t 将使用正确的参考。对于那些少数使用嵌入式系统或遗留系统具有非常古老的编译器,但是,你需要检查你的手册页。

In summary, for almost everyone, size_t will be the correct reference to use. For those few using embedded systems or legacy systems with very old compilers, however, you need to check your man page.

这篇关于什么是缓冲区的memcpy / memset的等能够处理的最大尺寸是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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