By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

PATH_MAX

P: n/a
Greetings.

I was under the impression that PATH_MAX (i.e., the maximum length, in
characters, of a fully-qualified filename) was part of standard C and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't compile
with gcc -ansi.)

Any suggestions for what to replace it with? Is there some relatively
safe arbitrary numerical constant I could use? I.e., what's the
greatest value I'm likely to encounter on today's popular platforms?
I'd hate to pick some value, x, thinking it's "big enough", and then
have some user complain when she tries to input a filename of length
x+1.

The program is aimed at logicians, mathematicians, and computer
scientists, so I expect most of them will be running Windows, DOS,
MacOS, or some variant of Unix (including GNU, Linux, BSD, OS X, etc.).
No need to worry about accommodating obscure embedded systems and
what-not.

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 14 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Tristan Miller wrote:
I was under the impression that PATH_MAX (i.e., the maximum length, in
characters, of a fully-qualified filename) was part of standard C and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't compile
with gcc -ansi.)

Any suggestions for what to replace it with?


FILENAME_MAX is available to standard C programs. It "expands to an
integer constant expression that is the size needed for an array of
char large enough to hold the longest file name string that the
implementation guarantees can be opened". Note, though, that this is
quite different from the "maximum length [...] of a fully-qualified
filename". Also, some systems have no such maximum, or at least a
maximum that is larger than any array you'd want to allocate. It's
usually better to dynamically allocate the buffer where possible (and
thus handle arrays of arbitrary size).

Jeremy.

Nov 14 '05 #2

P: n/a
Tristan Miller wrote:
I was under the impression that PATH_MAX (i.e., the maximum length, in
characters, of a fully-qualified filename) was part of standard C and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't compile
with gcc -ansi.)

Any suggestions for what to replace it with?


FILENAME_MAX is available to standard C programs. It "expands to an
integer constant expression that is the size needed for an array of
char large enough to hold the longest file name string that the
implementation guarantees can be opened". Note, though, that this is
quite different from the "maximum length [...] of a fully-qualified
filename". Also, some systems have no such maximum, or at least a
maximum that is larger than any array you'd want to allocate. It's
usually better to dynamically allocate the buffer where possible (and
thus handle filenames of arbitrary length).

Jeremy.

Nov 14 '05 #3

P: n/a
Greetings.

In article <sl*******************@hehe.cl.cam.ac.uk>, Jeremy Yallop
wrote:
Tristan Miller wrote:
I was under the impression that PATH_MAX (i.e., the maximum length,
in characters, of a fully-qualified filename) was part of standard C
and
defined in <limits.h>, but apparently I am wrong. (At least, I can't
find it in the C9X draft, and a trivial program using it won't
compile with gcc -ansi.)

Any suggestions for what to replace it with?


FILENAME_MAX is available to standard C programs.


Ah, thank you. Is this in C89 or only in C99?

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 14 '05 #4

P: n/a
In <73****************@ID-187157.news.dfncis.de> Tristan Miller <ps********@nothingisreal.com> writes:
Greetings.

In article <sl*******************@hehe.cl.cam.ac.uk>, Jeremy Yallop
wrote:

FILENAME_MAX is available to standard C programs.


Ah, thank you. Is this in C89 or only in C99?


It's C89, so you can safely rely on its availability.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.