Re: Is there a convention mandating macros to be all-uppper-case?

Tech-Archive recommends: Fix windows errors by optimizing your registry



ultranet wrote:
"Ulrich Eckhardt" wrote:
I may add that the (very good!) book "C++ Coding Standards" by
Sutter and Alexandrescu suggest that a) all macros are uppercase and
b) only macros are uppercase for that very reason. However, there is
existing practice to make constants from both constant objects and
enumerations all uppercase and assert() isn't uppercase either,
although it should.

How would you change the following enum?

enum eMyEnum {
eINVOKE,
eINVOKE_AND_WAIT
};

I'd like to make it clear that each constant is an enum member,

I've not seen a worse instance of Hungarian Notation Syndrome.

If you need to isolate those constants, a better way would be

struct InvocationType {
enum type { INVOKE, INVOKE_AND_WAIT };
};
... InvocationType::INVOKE ...

The fact that it's right after the scope resolution should tell everybody
interested to know that it's not a macro.

by
using EINVOKE would look like an error. I'm not sure about standard
headers, but in other headers i see some like above, and some
all-cap, w/o e, like INVOKE.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


.



Relevant Pages

  • Re: Code Review please.
    ... You really don't need MFC for this program. ... In addition to MFC serving to increase complexity & obfuscation and ensuring non-portability, the use of Microsoft "T" macros does the same. ... Identifiers starting with underscore followed by uppercase letter are reserved for the implementation. ... That's very uncommon, resulting in code that looks awful and inconsistent with Windows convention tab size 4, or *nix convention tab size 8. ...
    (microsoft.public.vc.mfc)
  • Re: Is there a convention mandating macros to be all-uppper-case?
    ... Alexandrescu suggest that a) all macros are uppercase and b) only macros ... How would you change the following enum? ... If you were to follow standard headers, you would call all identifiers _Foo ...
    (microsoft.public.vc.language)
  • Re: Malcolms new book - Chapter 1 review
    ... convention that macros shall be uppercase. ... write all my macros in uppercase, function-like or otherwise. ...
    (comp.lang.c)
  • Re: Multiple IF Scenario
    ... Frank Kabel ... > Lowercase does not work, but uppercase does. ... > Is it possible without using Macros? ...
    (microsoft.public.excel.misc)
  • Re: Pascal -> C
    ... I worked on a project where the error macros looked like this ... Or in this case, even better, use an enum. ... enum SystemError ... sub-systems to have semi-independent error list. ...
    (comp.lang.c)