Naming

Karl Heuer karl at haddock.ima.isc.com
Fri Mar 2 03:45:14 AEST 1990


In article <5016 at scolex.sco.COM> seanf at sco.COM (Sean Fagan) writes:
>In article <MCDANIEL.90Feb27103334 at amara.amara.uucp> mcdaniel at amara.uucp (Tim McDaniel) writes:
>>Are standard library names utterly and completely reserved, or can I
>>fake it with #define, as in
>>	#define malloc(bytes)	my_malloc(bytes, __FILE__, __LINE__)

The #define itself is legal (provided you first #undef any old one), but...

>You may not fake it.  [Undefined behavior if you do.]

I believe that's correct.  The problem is that some other routine from the
standard header might be implemented as a macro that invokes malloc(), and
could conceivably depend on some magic semantics that are not preserved by
your clone.

Elsewhere, Tim said:
>Suppose I just want to put a wrapper around a system function.  For instance,
>free given a NULL argument could just do nothing (if my system's supplied
>free would abort in such a circumstance).

Wait a minute.  If your system doesn't already do free() right, then it isn't
ANSI conformant, and so it doesn't matter what the ANS says is legal.  (As
Doug has said, the Standard does not attempt to impose constraints on those
implementations that do not obey the constraints of the Standard.)

You are trying to *provide* ANSI semantics on what is otherwise a non-ANSI
implementation.  Go ahead and write your own wrapper functions (but keep in
mind that they may have to be tailored to the system; in other words, you
can't expect to do it portably).

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.std.c mailing list