A question on C programming style

Michael Stefanik mike at bria.UUCP
Mon Apr 15 06:10:48 AEST 1991


In an article, wirzenius at cc.helsinki.fi (Lars Wirzenius) writes:
|I very much prefer style 1. Style 2 will very likely cause multiple
|inclusions, which at best wastes time (the compiler has to process each
|include every time), and at worst causes errors, since not all headers
|can be included multiple times. The only exception is an include file,
|whose only purpose is to include a set of headers that are needed in all
|or most of the source files in a given project.

Actually, if the include files are written correctly, very *little* time
is wasted and no errors are produced.  It's a simple matter of wrapping
the include file in:

	#ifndef _STDIO_H_
	#define _STDIO_H_
		.
		.
	#endif /* _STDIO_H_ */

Personally, I have found that nested includes are both convenient, and
make a great deal of sense.

-- 
Michael Stefanik, MGI Inc, Los Angeles | Opinions stated are never realistic
Title of the week: Systems Engineer    | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
If MS-DOS didn't exist, who would UNIX programmers have to make fun of?



More information about the Comp.lang.c mailing list