TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Winston van Oosterhout
from: Paul Edwards
date: 1995-03-20 08:17:50
subject: ANSI C vs. API calls

WvO> There are several API calls available that seem to do the same thing as 
WvO> standard ANSI C functions, like open() vs. DosOpen(), mkdir() vs. 
WvO> DosCreateDir() and a whole bunch more that are related to file I/O.

Neither open() nor mkdir() are ANSI C functions.

WvO> Is there any difference in code efficiency, EXE size and speed when the 
WvO> OS/2 API calls are used?

EXE size should be smaller if you use the Dos* functions.  And
it should be faster.  However, more than likely, this sort of
thing would make your program run 0.01% faster if you switched.
Use a profiler to find out where the bottleneck is.

WvO> Take mkdir() as an example. I don't need to set EA's when creating a 
WvO> particular directory, so I could be using both mkdir() and DosCreateDir(). 
WvO> I already make use of a lot other Control Program calls like 
WvO> DosSetPriority(), if that would make a difference. And the code doesn't 
WvO> have to be portable to other operating systems.

Just because you don't need to port it now, doesn't mean you won't
in the future.  The more portable you make it, the more chance it
has of being reused.  I personally in the above example would have
used fopen() to open the file, which is an ISO C function, and I
would use DosCreateDir() to make the directory because then I am
relying on functions provided by the operating system rather than
relying on functions provided as extensions to the particular
compiler I happen to be using.  E.g. there is no mkdir() function
on C/370 V 2.0, a 100% conforming ISO C compiler for IBM mainframes.  
BFN.  Paul
@EOT:

---
* Origin: This is just another kludge line like SEENBY (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.