TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Paul Edwards
from: Mike Bilow
date: 1995-10-08 15:49:54
subject: C Set ++

Paul Edwards wrote in a message to Murray Lesser:

ML> standard, non-ANSI library functions have an underscore as the leading
ML> symbol in the function name.

PE> There is no requirement for this, unless they interfere with
PE> the namespace of the resultant executable.  You will find
PE> that with a compiler such as Borland, which has a kbhit(),
PE> you can create your own function called kbhit(), and it will
PE> not clash with the one that Borland provide.  You are free
PE> to be blissfully unaware that they provide such a function
PE> as an extension, and so long as YOU follow the ISO standard,
PE> your program will compile, link and run properly.

It is bad practice, in my opinion, for a compiler vendor to supply
functions with names which make it hard to distinguish non-portable
functions from portable functions.  Many Borland C programmers get tripped
up when they try to use a standard compiler, because they are duped into
thinking that functions such as outtext() are parts of the C language like
printf().

In addition, you can get into very bad trouble with Borland C by replacing
library functions, since many of them call each other.  If you decide, for
example, to replace malloc() and free(), then you will find that realloc()
still calls into the original malloc() rather than your new one.  While
replacing malloc() and free() is not the kind of thing that the average
programmer should be doing, it certainly should be properly supported.

There a lot of these little problems in the Borland library, most of them
rather innocuous until they get you.  Another unreplaceable function is
tmpnam(), since the original function will still be secretly called by
fclose() for a file created with tmpfile().  The ANSI C standard specifies
in this case that tmpnam() shall behave as if no other library function
calls it, meaning that it can be replaced, but Borland interprets that
creatively to mean that replacing the function leaves the other library
functions calling the original version.

I have gone around with the Borland C library enough times to know that it
has serious problems for any but the most unambitious programmer.  I think
the last straw was when I looked in the Borland library source and found a
value being set to -1U.  Is that (unsigned)(-1)?  Or is it (unsigned
long)(-1)?  Or is it both at once?

-- Mike


---
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 323/107 150 3615/50 396/1 270/101 712/515 711/808 809 934

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™.