Path: utzoo!attcan!uunet!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.std.c Subject: Re: Naming Message-ID: <16064@haddock.ima.isc.com> Date: 1 Mar 90 16:45:14 GMT References: <1990Feb23.184656.3110@siia.mv.com> <16021@haddock.ima.isc.com> <5016@scolex.sco.COM> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 31 In article <5016@scolex.sco.COM> seanf@sco.COM (Sean Fagan) writes: >In article mcdaniel@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@ima.ima.isc.com or harvard!ima!karl), The Walking Lint