Re:Google C++ Style Guide
by _delirium on Sunday February 20, 2011 @03:09PM
(#2242865)
Huh, I don't think I've seen this constant naming convention before:
[ Parent
| on HN ]
It's also used by Apple in all of their Cocoa and CoreFoundation code. An example from CoreFoundation would be their constant CFAllocator references:
const CFAllocatorRef kCFAllocatorDefault;
const CFAllocatorRef kCFAllocatorSystemDefault;
const CFAllocatorRef kCFAllocatorMalloc;
const CFAllocatorRef kCFAllocatorMallocZone;
const CFAllocatorRef kCFAllocatorNull;
const CFAllocatorRef kCFAllocatorUseContext;We used that C++ constant naming convention at EA, too. I like it because it nicely differentiates C++ typed constants from preprocessor constants and macros (which we SPELLED_THUSLY).
Yeah, it appears it's actually quite common, and I must be one of the last people to be surprised by it. =] I've never been part of a major multi-person C++ project, though, so my stylistic conventions are a mixture of C conventions and the conventions used in the STL. I tend to SPELL_THUSLY even C++ typed constants, though I have also seen them PascalCased (but then, unless context makes it sufficiently clear, they can look like class names).
And useful if the number of days in a week ever changes.