I saw a lot of questions concerning what should be preferred between static const vs #define vs enum.
In none of them was discussed the aspect of resources, which is important in embedded system.
I don't like to use #define
but it doesn't consume resources like static
. What about enum
, does in consume RAM\ROM?
In addition, I was told that if i use e.g. const int
it will not consume either RAM nor ROM, assuming I do not use pointer\reference to this variable.
Is this true?
If this is true, wouldn't it be a good solution to use const int
inside a namespace
in order to save resources?
Remark: I am using C++ 2003 standard and can't use 2011 standard. (I already saw enum class
and constexpr in 2011, but i can't use them.)