Example:
#define Var1 35
static const int Var1( 35);
So while #define
replaces everywhere that I've used Var1
with 35
at compile time (which I presume makes the compile time slightly longer, if you have a lot of them, as it parses the code), using a static const int
makes the compiler consider it a variable.
Does this mean that when using static const int
it'll increase the memory imprint of my program because it has to use memory for all those constants, or is this overhead pretty much optimised out by the compiler anyway?
The reason I ask is because I'm wondering if it'd be better, for situations like this, to have them as static const int
s in debug mode (so you can easily see the values while debugging) but make them #define
s in release mode so it would make the program smaller.