2015-11-30 10:31 AM
Hello,
Using a lot of global variables modified into ISR sections, I use a lot the ''volatile'' keyword when needed.volatile int foo;int square(int din){ return din*din;}result = square(foo); // Does not compile: cast errorActually, this kind of C-code are not supported by IAR: ''int'' type is not compatible with ''volatile int'' type.The obvious solution is to do a cast:result = square((int)foo); // Compile very well but absolutely boring!With big projects, many structures and many functions with many parameters doing a cast for each parameter is very time-consuming and does not render the code very clear.Is there a way to tell to the compiler: ''Don't annoy me with volatile uncasted types!'' ?Thank you #volatile-cast-type2015-11-30 01:29 PM
You should not need to typecast since the ''volatile'' is only a type qualifier.
You show no declaration of ''result''.I tried similar code in CrossStudio, which uses the GCC compiler, and it works fine.Perhaps you should be asking the folks at IAR about this?2015-12-01 12:00 AM
> result = square(foo); // Does not compile: cast error
I don't know the IAR ARM compiler in detail, but that is probably not the full truth. Gcc has an option ''
-Werror
'' which makes all warnings to errors. The IAR compiler surely has something similiar, and you, or the project creation wizard, have set it. With gcc, you can set ''-Wall
'' (and ''-Wextra
'') instead to be informed about such issues, without failing the build.