11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVR!W (10):[warning] [MISRA 3010]pointer arithmetic usedMISRA prohibits any kind of pointer arithmetic. This includes adding an integer to apointer <strong>and</strong> subtraction of an integer or pointer from ano<strong>the</strong>r pointer, e.g.:int i;int *bar(unsigned);int *f(int *p, int *q); int *f(int *p, int *q){if(i < 33) {return 1 + p; // WARNING: pointer +integer} else {if(i < 55) {return p - 1;// WARNING: pointer- integer} else {if(i < 77) {return bar(p - q); // WARNING: pointer- pointer} else {/* do nothing */}}}}return &p[2];// OKNote that array subscription ([]) <strong>and</strong> dereferencing (*, . <strong>and</strong> ->) operators areallowed, so it is usually possible to rewrite <strong>the</strong> code that uses pointer arithmetic so thatit modifies integer indices instead of changing <strong>the</strong> pointers <strong>the</strong>mselves. For example,<strong>the</strong> following functionint strlen(const char *s){int n = 0;while(*s != '\0') {s++; // WARNING}return n;}169

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!