memory-saving
Depends on how many times used There are two copies #define pi 3.14 // no memory at all#define pi 3.14 function(pi); // One copy
#define pi 3.14 function1(pi); // One copy function2(pi); // Probably another copy
double pi=3.14;
But you are doing the assignment each tick.- Declaring a var inside (if) or (for) or (while) vs declaring it outside. Which case is more memory-saving ?No difference. You save an assignment to zero with assignment while declaring.
- which style above is the most memory-saving style of coding ?No difference. You save a function call to b() with #3
Is there difference for RTos and OS? ;)
Question 1.
(A constant) vs (an initialized local var of the same type): which is more memory-saving ?
#define pi 3.14vs
Question 2.
Declaring a var inside (if) or (for) or (while) vs declaring it outside. Which case is more memory-saving ?
Question 3.
Please compare 3 following styles of coding:
which style above is the most memory-saving style of coding ?
I am looking forward to hearing advices from experts. Thanks.