For the sake of argument
CONSTANT refers to either a
- character literal 'a'
- double literal 0.05
- float literal 0.05F
- integer literal 360
- long integer literal 360L
- string literal "Hello World"
i.e values passed directly, in read-only way.
____________________________________________________________________________________________________________________________________________
Variables are something slightly different as they store the value in read/write memory, which means they can be changed/accessed at some point(s) through their name identifier.
A variable value cannot be changed generally if the variable is declared with the
const type qualifier (which makes it a constant variable) or passed as a function argument.
____________________________________________________________________________________________________________________________________________
- Code: Select all
xvelocity = 40.0;
In that case, xvelocity is a variable type double and we change it (by assigning) to contain 40.0 which is passed as a double literal.
____________________________________________________________________________________________________________________________________________
A MACRO is what actually can be identified (adhering the syntactic standards) by its capitalized name identifier
a MACRO is a textual replacement of code
- Code: Select all
#define XVEL xvelocity
Will define XVEL to be used as if xvelocity is used instead.
- Code: Select all
#define XVEL_IS_40 xvelocity = 40.0
Can be used like that
- Code: Select all
XVEL_IS_40;
instead of:
- Code: Select all
xvelocity = 40.0;
Although I would prefer a MACRO function for such preemption (but that will go again way too far)