On 08/30/2016 02:22 PM, Jens Bauer wrote:
Hi all.

I know it's possible to declare a variable 'read-only' by using 'const'.

When working with microcontrollers (small ICs, which often requires you to 
write your code at driver-level), you need to be able to declare a structure 
member 'read-only', 'write-only' or 'read+write'.
In addition to that, it would definitely be handy to declare variables 'no 
access'

So I'd like to propose the following two attributes, which is 'off' by default 
(eg. read access + write access):
__attribute__((not_readable))
__attribute__((not_writable))

Any combination of those allowed.

You can already do this:

“
int my_register;

#define store_my_register(val) (my_register = (val))

#pragma GCC poison my_register
”

And GCC will reject any access to my_register.

Is this solution good enough?

Florian

Reply via email to