On 28-Jun-15 9:19 PM, Stefan Ram wrote:
> guide A:
>
> Don't use macros! OK, (...) treat them as a last resort.
> (...) And #undef them after you've used them, if possible.
>
> guide B:
>
> #undef should not normally be needed. Its use can lead
> to confusion with respect to the existence or meaning of
> a macro when it is used in the code
>
Ordinary include guards are incompatible with guide A. Well I could
agree with a preference for #pragma once instead of include guards (and
just don't support any e.g. IBM compiler that doesn't support the
pragma), but /requiring/ that one doesn't use include guards is IMHO to
go too far. It's more work and less clear, but if someone wants to, hey.
As an example that's incompatible with guide B, in Windows desktop
programming one will normally, nowadays, defined UNICODE before
including <windows.h>. The definition doesn't matter, just that it's
defined. But if it is defined in code and there is a previous definition
one will get a sillywarning with e.g. g++ or Visual C++. And a simple
solution is to #undef it, like this:
#undef UNICODE
#define UNICODE
#include <windows.h>
And this is very normal code.
Rules to be mechanically followed are generally not compatible with C++
programming, which requires Some Intelligence Applied™.
Therefore I think that neither guide referred to and quoted above, can
be of very high quality.
Cheers & hth.,
- Alf
[Sorry, yet again I inadvertently applied Google Groups experience and
hit "Reply". I'm currently searching for the "Unsend" button.]
--
Using Thunderbird as Usenet client, Eternal September as NNTP server.