We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I am creating the MAKELONG, HIWORD, LOWORD like in Window's C programming.
However, when I create the macro's below I get the error message that follows.
Anyone have any suggestions on why ARM is complaining? I've never had an issue with standard C with this type of macro before.
I thought that maybe the compiler did not know what type of variable "val" was, so I defined the variable in the macro (long val) but that did not help either.
#define MAKELONG (x,y) ((((x) << 16) & 0xFFFF0000) + (y)) #define LOWORD (val) ((val) & 0xFFFF) #define HIWORD (val) (((val) >> 16) & 0xFFFF)
Source\message.c(23): error: #20: identifier "x" is undefined Source\message.c(23): error: #20: identifier "y" is undefined
Usage of macro:
lCmd = MAKELONG ((0xFFF1), (0x111F));
Just a question for you.
The preprocessor is a "dumb" search/replace engine.
How will a preprocessor know that (x,y) is the arguments of a macro and that the information following on the line is the replace rule?
Note that you have written:
#define MAKELONG (x,y) ((((x) << 16) & 0xFFFF0000) + (y))
What do you think happens if you rewrite that line as:
#define MAKELONG(x,y) ((((x) << 16) & 0xFFFF0000) + (y))
Do you see any difference between the two lines? Does it surprise you, or is it actually quite logical - if you consider exactly what capabilities the preprocessor has (and hasn't)?