Using ARM CC compiler V5.06 update 3 (build 300). I see some quirkiness with macro calculations when using a preprocessor macro that refers to other macros. It seems the value is byte trimmed. Tried several optimization flags but the behavior is the same.
bleyer.org/.../armcc_macrobug.gif
If I extract the function from the project and compile it standalone then the issue is gone, so I suspect the preprocessor or the compiler gets confused from whatever happens on a bigger project.
After reading your description and watching the gif for far too long, I still don't see detail of what you're saying that you think is wrong. Why don't you try stating what you provide, what you expect and what you see?
Sorry for being so laconic. I though the issue was more evident.
In both cases pck_MAXDATASIZE should evaluate to 512-4=508=0x1fc. However when letting the preprocessor do the calculation, the register is loaded with 0xfc instead of 0x1fc. I.e. it seems to drop the high byte from the target uint16_t argument.
Also notice that the previous calculation using pck_MAXDATASIZE is incorrect too in the assembler listing.
Sorry, but i don't have sufficient patience to look at a constantly moving image while i'm trying to examine the code. Screenshots or extracts of code listing would (at least for me) be far easier to examine.
My first impression though is doubt about your explanation for what you're seeing.
Have the compiler output the preprocessing pass and review that...
Make sure it is generating current browse data
Not sure if the IDE is aware of command line defines, and how that might impact if it thinks the #ifdef's are taken or not.
printf() the individual constants, confirm assumptions...
Pier, many thanks for your reply.
As you suggested, I had tried everything but the problem persisted. I ended up inspecting the project file and the XML was corrupted! There was a dangling pck_BUFFERSIZE definition along with some garbage text under the <Cads> and <Define> sections that didn't show up in the IDE, but I found was being passed to the compiler in the command line. I recreated the project file from scratch and now everything works as expected.
This is not the first time I have problems with the files that uVision handles. There is also another bug in the latest releases that, every once in a while, it complains that it cannot save a source code file, and if you close the IDE, the file is gone. It seems to originate from the way it handles temporary backup files in Windows. Perhaps the corrupt project file is another aspect of the same problem.
Best.