Would you expect cppcheck to handle that sort of compiler extension, or is a macro always going to be needed? I think I've seen that before with a different compiler, although it was many years ago. And to be fair this is a very old IAR compiler. I don't know if they do the same thing now.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I couldn't find any sample projects. I found a few files in the compiler directory. Some of them trigger this and some don't. It seems that if the address is a simple number then it is OK, but if the address is an expression then it throws a syntax error.
Zip file attached. EEP.c is mine, the other two are IAR samples.
The IAR C compiler for embedded MSP430 uses a non-standard syntax to declare variables at absolute locations.
Cppcheck doesn't like the @ character so it aborts any further processing of the file with syntaxError.
It's easy to work around this by using a macro to define the absolute variables:
Would you expect cppcheck to handle that sort of compiler extension, or is a macro always going to be needed? I think I've seen that before with a different compiler, although it was many years ago. And to be fair this is a very old IAR compiler. I don't know if they do the same thing now.
We want to handle that. I even thought we did. Yes I have also seen that syntax with some other compiler, do not remember which one.
Problem is I don't have any real world such code.
Do you know if there are any IAR sample project(s) that I can use to test Cppcheck?
I couldn't find any sample projects. I found a few files in the compiler directory. Some of them trigger this and some don't. It seems that if the address is a simple number then it is OK, but if the address is an expression then it throws a syntax error.
Zip file attached. EEP.c is mine, the other two are IAR samples.
Thanks! I created ticket https://trac.cppcheck.net/ticket/9809