void*

Karl Heuer karl at haddock.ima.isc.com
Thu Aug 16 06:40:35 AEST 1990


In article <13548 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>That's why the implementation of memchr() along the lines I suggested should
>not include the standard header.  Indeed, I wouldn't include the relevant
>header in most implementations of standard library functions, since it
>usually isn't either necessary or useful to do so.

I would consider it bad style to take advantage of the same-representation
clause like that; I believe it was added to grandfather in the pre-ANSI code
that contained explicit declarations for functions like malloc().  I would
simply implement memchr() using `void *', with casts as appropriate.  It's a
minor wart.

For memchr(), you want the header anyway in order to get the definition of
size_t.  (You could get it from some other header, but why go out of your way
to be difficult?)  Even if this were not the case, I'd include it just to let
the compiler confirm that the prototype in the header agrees with that in the
source.

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



More information about the Comp.std.c mailing list