Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!cmcl2!acf5!sabbagh From: sabbagh@acf5.NYU.EDU (sabbagh) Newsgroups: comp.lang.c Subject: Re: Including Message-ID: <841@acf5.NYU.EDU> Date: 13 Sep 89 13:45:44 GMT References: <71@motto.UUCP> Reply-To: sabbagh@acf5.UUCP () Organization: New York University Lines: 44 In article <71@motto.UUCP> dave@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, , 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 > is included at the same time. > >Here are the ideas I have considered: > >1. Document the requirement > [stuff deleted] >2. Include at the top of my header As far as I have seen, 1. is the usual approach. If you want to have included in your own header file (as per 2.) the best way to assure that it works is 1. Scan stddef.h for some symbol defined with an #define, say, #define FOO 2. In your header, use the following: #ifndef FOO #include #endif This will guarantee that your header file will always have the stddef.h loaded, but it will cause problems for the user if they try to #include AFTER #including your header. A third approach (if your are REALLY serious), is to copy those parts of into your own header file and #undef them when your are done. This resolves all the above problems, but gives up something in portability. Isn't C great? Hadil G. Sabbagh E-mail: sabbagh@csd27.nyu.edu Voice: (212) 998-3285 Snail: Courant Institute of Math. Sci. 251 Mercer St. New York,NY 10012 186,282 miles per second -- it's not just a good idea, it's the law!