473,408 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

FOPEN_MAX minimum value

Hi there,

I was wondering what the standard (C89) states what the minimum value of
FOPEN_MAX should be? K&R just state that FOPEN_MAX is
implementation-defined and when googling for an answer I found that GNU's
libc defines FOPEN_MAX to be at least 8, including stdin, stdout and
stderr.
Does GNU's definition reflect the standard, or is it their
implementation of the standard?
Nov 15 '05 #1
5 5691
"Bas Wassink" <im*********@gmail.com> wrote in message
news:pa****************************@gmail.com...
I was wondering what the standard (C89) states what the minimum value of
FOPEN_MAX should be? K&R just state that FOPEN_MAX is
implementation-defined and when googling for an answer I found that GNU's
libc defines FOPEN_MAX to be at least 8, including stdin, stdout and
stderr.
Does GNU's definition reflect the standard, or is it their
implementation of the standard?


It's still 8 in C99, including the three standard streams.
Many implementations I know make this value considerably larger,
however.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Nov 15 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bas Wassink <im*********@gmail.com> writes:
I was wondering what the standard (C89) states what the minimum
value of FOPEN_MAX should be?
[C99, §7.19.3#15] "The value of FOPEN_MAX shall be at least eight,
including the three standard text streams."
K&R just state that FOPEN_MAX is implementation-defined and when
googling for an answer I found that GNU's libc defines FOPEN_MAX to
be at least 8, including stdin, stdout and stderr. Does GNU's
definition reflect the standard, or is it their implementation of
the standard?


Both.

[Using GNU libc 2.3.5]

$ rgrep FOPEN_MAX /usr/include
/usr/include/bits/stdio_lim.h:#if defined __need_FOPEN_MAX || defined _STDIO_H
/usr/include/bits/stdio_lim.h:# undef FOPEN_MAX
/usr/include/bits/stdio_lim.h:# define FOPEN_MAX 16
/usr/include/stdio.h: FOPEN_MAX Minimum number of files that can be open at once.

So the *minimum* is 16 with my version. The actual maximum depends on
the system configuration. On a typical GNU/Linux system this will be
unlimited, but may be limited using RLIMIT_NOFILE; see getrlimit(2)
and setrlimit(2) (but this is standardised by POSIX/SUS, not C).
Regards,
Roger

- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFDGyaWVcFcaSW/uEgRAmTrAJ4n2rZoXGbuSgYp7t+qZ3dWEihXxQCg7IQ4
C+rylg27sgPjeeYedwuXme0=
=iu90
-----END PGP SIGNATURE-----
Nov 15 '05 #3
Bas Wassink wrote:

I was wondering what the standard (C89) states what the minimum value
of FOPEN_MAX should be?


Yes, 8, but I'm curious as to why you care?

Either a file is going to open or it isn't. Are you thinking of
writing code that's going to stop opening files when it hits
FOPEN_MAX open streams? If so, why?

--
Peter

Nov 15 '05 #4
On Sun, 04 Sep 2005 22:54:22 -0700, Peter Nilsson wrote:
Bas Wassink wrote:

I was wondering what the standard (C89) states what the minimum value
of FOPEN_MAX should be?


Yes, 8, but I'm curious as to why you care?

Either a file is going to open or it isn't. Are you thinking of
writing code that's going to stop opening files when it hits
FOPEN_MAX open streams? If so, why?


I'm writing a cross-assembler for 65xx-based systems. The parser should
support #include statements, but since the minimum value of FOPEN_MAX is
way too little (even my C64 can do better), I'll have to rewrite my code.

Right now, my code just opens a new file when hitting an #include
statement. I'm going to have to change that so it'll store the position in
the current file, close it, open the new file, parse it (maybe hitting
another #include), close it, reopen the previous file, restore the
position in the file and continue parsing.

Hopefully this clarifies my reasons for wanting to know...
Nov 15 '05 #5
"Bas Wassink" <im*********@gmail.com> wrote in message
news:pa****************************@gmail.com...
On Sun, 04 Sep 2005 22:54:22 -0700, Peter Nilsson wrote:
Bas Wassink wrote:

I was wondering what the standard (C89) states what the minimum value
of FOPEN_MAX should be?


Yes, 8, but I'm curious as to why you care?

Either a file is going to open or it isn't. Are you thinking of
writing code that's going to stop opening files when it hits
FOPEN_MAX open streams? If so, why?


I'm writing a cross-assembler for 65xx-based systems. The parser should
support #include statements, but since the minimum value of FOPEN_MAX is
way too little (even my C64 can do better), I'll have to rewrite my code.

Right now, my code just opens a new file when hitting an #include
statement. I'm going to have to change that so it'll store the position in
the current file, close it, open the new file, parse it (maybe hitting
another #include), close it, reopen the previous file, restore the
position in the file and continue parsing.

Hopefully this clarifies my reasons for wanting to know...


And it's a good reason. We had to do the same thing to the Whitesmiths
C compiler twenty years ago, once X3J11 settled on this small minimum
maximum for FOPEN_MAX.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Porthos | last post by:
Hi All, I'm trying to find the minimum value of a set of data (see below). I want to compare the lengths of these attribute values and display the lowest one. This would be simple if I could...
2
by: Hennie de Nooijer | last post by:
I have a problem (who not?) with a function which i'm using in a view. This function is a function which calculates a integer value of a date. For example: '12/31/2004 00:00:00" becomes 20041231....
2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
3
by: RobG | last post by:
I would like a query that will tell me the minimum non-zero value in a row. Say I have a table with a column called recordID that contains unique record IDs, and have a set of values named V1,...
2
by: Johannes Hammersen | last post by:
Hi, when I try to set the Minimum Date on a RangeValidator to 01.01.0001 I get an error, that 01.01.0001 can not be converted to a date. But the DateType can be 01.01.0001....
11
by: JJLaRocque | last post by:
Hi all, Is there a simple python function to return the list index of the minimum entry in a list of lists? ie, for , , ] to return 2,4. Or, same question but just for a list of numbers, not a...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
13
by: Ioannis Vranos | last post by:
Is there any mentioning in the standard of the number of bits of the various built in types, apart from char/signed char/unsigned char types? Or only about the minimum value ranges of them?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.