Naming

Martin Weitzel martin at mwtech.UUCP
Wed Feb 28 23:16:36 AEST 1990


In article <MCDANIEL.90Feb27103334 at amara.amara.uucp> mcdaniel at amara.uucp (Tim McDaniel) writes:
>drd at siia.mv.com (David Dick) writes:
>   [The names in the standard library are also reserved]
>   Remember that you can no longer "roll your own" version of any
>   of these routines.
>
>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__)

To be save, you should write a line #undef malloc before your
redefinition (because every library-function might be defined
as well as macro, if you include the appropiate standard header
- stdlib.h in this case).

To be save *and* portable you might even have to write:

#ifdef malloc
#undef malloc
#endif
#define <your own malloc>

The latter is *not* required in ANSI-C, because #undefs are
legal if the given name is not defined as macro.
-- 
Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83



More information about the Comp.std.c mailing list