c - Sending parameter to a #define -
i wonder know possible send parameter #define
macro selecting different output
for example:
#define row(1) lpc_gpio0 #define row(2) lpc_gpio3 #define row(3) lpc_gpio2
then in code create loop sending parameter
row(x)
this macro syntax doesn't exist.
moreover, can't possibly exist, because macros expanded before compiler compiles code. if x
isn't compile time constant, there never way determine replace in source code macro invocation.
if need index values, use array, e.g. (assuming these constants integers):
static int rows[] = { 0, lpc_gpio0, lpc_gpio3, lpc_gpio2 };
writing
rows[x]
would have effect seem have expected invalid macro syntax.
Comments
Post a Comment