Mail Archives: djgpp/1998/01/23/02:05:06
On 22 Jan 98, Eli Zaretskii was found to have commented thusly:
>
> On Thu, 22 Jan 1998, S. M. Halloran wrote:
>
> > This is a C language fundamental that you bring up. Constants should
> > never really be used in the code and should really be defined by
> > macros for the purpose of portability. If you always use the macro
> > symbols for constants for functions in the standard library (or
> > functions with well-understood portability), you should never have a
> > problem getting the code to work on different implementations. It is
> > a very rare case that numeric constants, rather than their symbolic
> > macros, would ever be used directly in the code.
>
> Unfortunately, this advice is useless in the case of `access', since
> some systems (TC is one of them, but there are others, even on Unix)
> don't define the R_OK, W_OK etc. symbols for the mode argument of
> `access'. On those systems, you *must* use numeric values if you
> call `access'. That's why I advise to avoid using this function.
>
I checked a TC++ v3.0 copy for access(), and indeed you're right.
Incredibly Borland did not define the constants with macros. What is
more bizarre is that Borland indicated in its portability table that
access() is portable with Unix. Why Borland borrows a function from
Unix, then fails to use the constants that were probably defined the
day that access() was conceived is vexing. Is it the case that
the earliest implementations of access() in Unix did, in fact, not
use macro symbols?
Mitch Halloran
Research (Bio)chemist
Duzen Laboratories Group
Ankara TURKEY
mitch AT duzen DOT com DOT tr
other job title: Sequoia's (dob 12-20-95) daddy
- Raw text -