|
From: | efrat |
Subject: | Re: unique identifiers for guard macros |
Date: | Wed, 05 Apr 2006 19:36:48 +0300 |
User-agent: | Mozilla Thunderbird 1.0.7 (X11/20051013) |
rmansfield@gmail.com wrote:
Why do you need unique guards? The reason why header guards are used is to prevent multiple inclusion of a file so the macros are based on the file name. For example, foo.h would have: #ifndef FOO_H #define FOO_H #endif Sorry if this isn't very helpful, but I don't see why you would need unique guards. Regards, Ryan Mansfield
FWIW, I think that MS agrees with you: in VC++, you can write #pragma once at the top of a file instead of guards.I guess that g++ is more hesitant to extend the language (for which MS is notorious). Since the preprocessor can do the trick (through unique guards), then that's that. Generating unique names sure is annoying, though. I try to include into the guard some information that includes both the file name, and the directory structure relative to the project's base directory.
[Prev in Thread] | Current Thread | [Next in Thread] |