[En-Nut-Discussion] Don't use the const attribute for non pointer arguments

Nathan Moore nategoose at gmail.com
Tue Mar 25 21:38:06 CET 2008


>
> I just read the coding style documentation. It says "*Don't use the
> const attribute for non pointer arguments"* but I don't think that's
> right. As far as I know avr-gcc puts the first 4 bytes of the arguments
> in registers. Therefore might be possible that it does help to optimize
> the code. Does anyone know anything about this, before I start
> researching?
>
This isn't likely to get you anything since the return value is often placed
in the same register(s) as the first argument.  Also, I don't think any
compilers could take advantage of it because const doesn't mean that the
location of the variable can't be moved, just that it's value can't be
changed.  For pointers to constant values this is not the case.

Nathan



More information about the En-Nut-Discussion mailing list