DIP62: Volatile type qualifier for unoptimizable variables in embedded programming

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 15 10:42:47 PDT 2014


On Tuesday, 15 July 2014 at 17:13:09 UTC, Johannes Pfau wrote:
> Why do shared variables have the privilege to prevent accessing 
> shared
> memory in inappropriate ways but it's fine to place the burden 
> of
> checking that all accesses to volatile memory are backed by 
> compiler
> barriers to the user? How is that 'first class' support?

Maybe it can be automated by a wrapper template?

struct Volatile(T)
{
   T val;
   void opAssign(T v)
   {
     volatile_store(val, v);
   }
}

extern(C) Volatile!byte led;

foreach(i;0..10)
{
   led=0;
   led=1; //blink
}


More information about the Digitalmars-d mailing list