ADC Home > Reference Library > Technical Q&As > Legacy Documents > Tools >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

C Open File Limit


Q: Our development group has encountered a problem with their Macintosh port (they are developing for the 68K only, under MPW 3.3.1 with the MPW C 3.2.4 compiler). They allocate a large number of FILE streams via fopen(), and eventually, the fopen() calls begin to fail. We believe that they have encountered MPW's limit of 20 open files.

A: Microsoft has provided a standard C library that has a larger static FILE stream buffer to circumvent this problem, and they would like get a similar MPW C library from Apple.

A: The _NFILES macro in stdio.h defines the maximum number of files that can be opened. This is set to 40 in the ETO #16 pre-release, SC-compatible, MPW libraries (otherwise it's 20). Support for more than 40 files is not planned, so there won't be a final version of libraries for MPW C with a larger open-file limit.

There is a possible workaround - use our low-level I/O calls instead of the stream I/O calls. The number of files you can open with low-level calls is limited only by available memory. (These calls are documented in the chapter on building MPW tools in Building and Managing Programs with MPW). Low-level I/O calls can be used in applications, but this isn't obvious because the documentation isn't well organized.

It's possible that our low-level I/O calls may not provide you with sufficient functionality for your port, assuming that you are using fprintf or a related function, and there is no low-level equivalent for this. If your usage is limited to getc/putc/fread/fwrite, it would be fairly simple to emulate these on top of low-level I/O using the low-level read and write functions. However, a better, long-term solution would be to move to the SC compiler and its associated libraries.

[Jun 01 1995]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.