_setmaxstdio_setmaxstdio

设置在 stdio 级别同时打开的最大文件数。Sets a maximum for the number of simultaneously open files at the stdio level.

语法Syntax

int _setmaxstdio(  
   int newmax   
);  

参数Parameters

newmax
stdio 级别同时打开的新的最大文件数。New maximum for the number of simultaneously open files at the stdio level.

返回值Return Value

返回newmax如果成功; 否则为-1。Returns newmax if successful; -1 otherwise.

如果 newmax 小于 _IOB_ENTRIES 或大于操作系统中可用的句柄的最大数量,则调用无效参数处理程序,如参数验证中所述。If newmax is less than _IOB_ENTRIES or greater then the maximum number of handles available in the operating system, the invalid parameter handler is invoked, as described in Parameter Validation. 如果允许执行继续,则此函数将返回 -1 并将 errno 设置为 EINVALIf execution is allowed to continue, this function returns -1 and sets errno to EINVAL.

有关这些及其他错误代码的信息,请参阅 _doserrno、errno、_sys_errlist 和 _sys_nerrFor information about these and other error codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.

备注Remarks

_setmaxstdio 函数将更改可能在 stdio 级别同时打开的最大文件数。The _setmaxstdio function changes the maximum value for the number of files that might be simultaneously open at the stdio level.

相比早期版本,现在 C 运行时 I/O 在 Win32 平台上支持更多的打开文件。C run-time I/O now supports many more open files on Win32 platforms than in previous versions. lowio 级别最多可同时打开 2,048 个文件(即,通过 _open_read_write 等 I/O 函数系列打开和访问)。Up to 2,048 files can be open simultaneously at the lowio level (that is, opened and accessed by means of the _open, _read, _write, and so forth family of I/O functions). stdio 级别最多可同时打开 512 个文件(即,通过 fopenfgetcfputc 等函数系列打开和访问)。Up to 512 files can be open simultaneously at the stdio level (that is, opened and accessed by means of the fopen, fgetc, fputc, and so forth family of functions). stdio 级别 512 个打开文件的限制可通过 _setmaxstdio 函数增加到最多 2,048 个。The limit of 512 open files at the stdio level can be increased to a maximum of 2,048 by means of the _setmaxstdio function.

因为诸如 fopenstdio 级别的函数是基于 lowio 函数生成的,2,048 的最大值是通过 C 运行时库访问的同时打开文件数的硬上限。Because stdio-level functions, such as fopen, are built on top of the lowio functions, the maximum of 2,048 is a hard upper limit for the number of simultaneously open files accessed through the C run-time library.

备注

此上限可能会超过特定 Win32 平台和配置所支持的文件数。This upper limit might be beyond what is supported by a particular Win32 platform and configuration.

要求Requirements

例程Routine 必需的标头Required header
_setmaxstdio <stdio.h><stdio.h>

有关更多兼容性信息,请参见“简介”中的 兼容性For more compatibility information, see Compatibility in the Introduction.

示例Example

请参阅 _getmaxstdio 了解使用 _setmaxstdio 的示例。See _getmaxstdio for an example of using _setmaxstdio.

请参阅See Also

流 I/OStream I/O