Question
General C question - volatile cast
Posted on November 30, 2015 at 19:31
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-type