Including <stddef.h>

David Adrien Tanguay datanguay at watmath.waterloo.edu
Wed Sep 13 16:10:07 AEST 1989


In article <71 at motto.UUCP> dave at motto.UUCP (dave brown) writes:
>I am writing a header file to be used by other programmers.  Within
>this file, one of the structures needs the type size_t.  This means
>that in order to compile properly, <stddef.h>, which defines size_t,
>must be included as well.  Since my header file will be used in
>programs I didn't write, I need to figure out how to make sure
><stddef.h> is included at the same time.

See section 4.1.2: the implementation must make the standard headers
idempotent (with the exception of assert.h, which relies on NDEBUG).
You can put <stddef.h> in your header file, and there should be no
problems if the user of your header file also includes <stddef.h>.
"...; each may be included more than once in a given scope, with no
effect different from being included only once, ..."

David Tanguay



More information about the Comp.lang.c mailing list