Path: utzoo!attcan!uunet!modcomp!joe From: joe@modcomp.UUCP Newsgroups: comp.lang.c Subject: Re: conditional includes Message-ID: <8000012@modcomp> Date: 20 Jan 89 19:53:00 GMT References: <8000011@modcomp> Lines: 34 Nf-ID: #R:modcomp:8000011:modcomp:8000012:000:1334 Nf-From: modcomp.UUCP!joe Jan 20 14:53:00 1989 Hi, fellow netlanders, Several of you responded to my query about what C compilers, if any, provide their users with a convenient conditional include facility. As promised, I'm summarizing (read: liberally plagiarizing) your letters in this response. 1. The Objective-C language (used on the NeXT) has exactly the feature described. The keyword used is "#import". 2. The "High C" compiler for the IBM PC/RT supports once-only includes. It prevents multiple includes based on filename, so referencing a file by different names will result in multiple inclusion. 3. One compiler (unnamed) has a cpp pragma "#pragma idempotent" that is inserted into the header file. Any subsequent include of that filename is skipped. 4. A combination of (3) and the original solution results in an effective solution which does not require any language extensions: replace "#pragma idempotent" with the lines: #ifdef #define and add a "#endif" to the end of the include file. Controlling multiple inclusion from within the file itself solves the problem mentioned in (2) as well as the excessive wordiness of the original solution. I have assumed that all respondents prefer to remain anonymous. My apologies if that assumption is wrong. joe korty uunet!modcomp!joe