This is the mail archive of the
mailing list for the GCC project.
Re: Proposal: readable and writable attributes on variables
- From: Florian Weimer <fweimer at redhat dot com>
- To: Jens Bauer <jens-lists at gpio dot dk>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 1 Sep 2016 15:21:27 +0200
- Subject: Re: Proposal: readable and writable attributes on variables
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com>
On 08/30/2016 02:22 PM, Jens Bauer wrote:
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):
Any combination of those allowed.
You can already do this:
#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?