delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/22/03:29:57

Message-Id: <199801220827.KAA08443@ankara.duzen.com.tr>
Comments: Authenticated sender is <mitch AT ankara DOT duzen DOT com DOT tr>
From: "S. M. Halloran" <mitch AT duzen DOT com DOT tr>
Organization: User RFC 822- and 1123-Compliant
To: djgpp AT delorie DOT com
Date: Thu, 22 Jan 1998 10:28:06 +0200
MIME-Version: 1.0
Subject: Re: access() in DJGPP and TC/BC
In-reply-to: <01ISNOZW1WPE008ULX@cc.uab.es>

On 22 Jan 98, X DOT PONS AT UAB DOT ES was found to have commented thusly:
> 
> I have found a problem when porting TC/BC code to DJGPP because of
> the different meanings of the accesibility mode ("amode", the second
> parameter) of the access() function.
> 
> * DJGPP defines these accessibility modes:
>   R_OK (=0x02)  Request if the file is readable.  Since all files
>   are
>                 readable under MS-DOS, this access mode always
>                 exists.
>   W_OK (=0x04)  Request if the file is writable.
>   X_OK (=0x08)  Request if the file is executable.
>   F_OK (=0x01)  Request if the file exists.
>   D_OK (=0x10)  Request if the file is really a directory.
> 
> * TC/BC define these accessibility modes:
>     06  ¦ Check for read and write permission
>     04  ¦ Check for read permission
>     02  ¦ Check for write permission
>     01  ¦ Execute (ignored)
>     00  ¦ Check for existence of file
> 
> This is problematic because the meanings are very different although
> the code compiles and runs perfectly. Note, for example, that a 4
> (read permission) in TC/BC implies a W_OK (write permission) in
> DJGPP.
> 
[....]

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.

I believe some coders are so fastidious about keeping 
numeric constants out of code that they insist on a symbolic macro 
for every constant except for zero.

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019