I think you heard that from Scott Meyers in his book Effective C++. :-)

On 09-Feb-2011 10:34 AM, "Travis Daveez" <[email protected]> wrote:

Hi everyone,

I heard somewhere a while back that when
defining variables such as:
#define DEFNAME 42
is not always the best way to got about
defining a constant because it is possible
that the preprocessor will substitute 42
everywhere DEFNAME is seen and thus DEFNAME
is not put into the symbol table. This could cause
troubles when debugging for the number 42, and
not knowing where 42 was defined such as in a header
file you didn't write.

Instead it was proposed to declare DEFNAME as
const int DEFNAME = 42;

I'm thinking  that if you use define a lot in your code and
convert them all to consts then that increases the number
of variables and thus size of the stack. Would you say this is
the main downside and why we don't see this as a general
rule used in most projects? Or is there something else I am
not thinking of?

Cheers
Travis


_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to