Including <stddef.h>

dave brown dave at motto.UUCP
Wed Sep 13 00:09:33 AEST 1989


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.

Here are the ideas I have considered:

1. Document the requirement

   The documentation that tells the programmers to use <myheader.h>
   would also tell them it requires <stddef.h>.

   I would rather make things automatic, since if they neglect to include
   <stddef.h>, the result will be a compile error inside my file, which
   is a rather messy way of telling them they left something out.

2. Include <stddef.h> at the top of my header

   What if they have already included it?  Is it guaranteed that it can
   be included more than once without causing errors?

Are there any other ideas? What should I do?

Thanks for your help,
	Dave

 -----------------------------------------------------------------------------
|  David C. Brown		|  uunet!mnetor!motto!dave		      |
|  Motorola Canada, Ltd.	|  416-499-1441 ext 3708		      |
|  Communications Division	|  Disclaimer: Motorola is a very big company |
 -----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list