hardcoded constants

Dave Jones djones at megatest.UUCP
Thu Dec 15 08:52:17 AEST 1988


>From article <33459 at think.UUCP>, by barmar at think.COM (Barry Margolin):
...
> 
> My rule of thumb is that if it needs a comment, it should be a
> manifest constant, not a hardcoded literal.  The name of the constant
> then serves as self-documentation.
> 

Your thumb is okay with me, so long as you add the proviso that
if the constant is only used in one place, its scope of definition
is restricted to that place.  I'll try to say that in English.
I don't want the #define to be exiled to some #include file unless
it really is used all over the place.  If it is local, keep it local.



More information about the Comp.lang.c mailing list