Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.lang.c Subject: Re: A solution to the multiple inclusion problem Message-ID: <2552@munnari.oz.au> Date: 27 Oct 89 13:49:14 GMT References: <14240@well.UUCP> <2550110@hpisod2.HP.COM> Sender: news@cs.mu.oz.au Lines: 18 In article <2550110@hpisod2.HP.COM>, decot@hpisod2.HP.COM (Dave Decot) writes: > > Why does everybody feel compelled to reinvent this wheel? > Because there's no STANDARD (**HINT**) way to do it that has any > hope of efficiency!! But we've been shown several. The simplest is the two-files-per-header method: your file foo.h foo1.h #include "foo.h" #ifndef FOO_H /* whatever */ #define FOO_H 1 #include "foo1.h" #endif You can apply this technique even when foo1.h is a header file supplied by someone else: foo.h gets rescanned every time but this is file open + file close + reading four lines, and the #pragma once hack saves you just the cost of reading three lines. Big saving, huh?