DIP62: Volatile type qualifier for unoptimizable variables in embedded programming
Meta via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 15 11:38:37 PDT 2014
On Tuesday, 15 July 2014 at 18:30:11 UTC, Johannes Pfau wrote:
> No, this doesn't work with Volatile!:
>
> struct A
> {
> private int _val;
> int read(){ return val+val };
> int read(bool volatile)() { auto tmp = val; return tmp*tmp;
> };
> }
struct A
{
private int _val;
int read(bool volatile)()
{
static if (volatile)
{
auto tmp = val; return tmp*tmp;
}
else
{
return val+val;
}
};
}
And you are no worse off than before. This template can only
generate 2 possible functions, and the instantiations are also
cached so as far as I know, there's no code bloat.
> opDispatch sounds _awesome_ for systems with a few KB of SRAM.
> People here always have nice ideas but will you implement it
> and tune it until it has as little overhead as the C version?
That's not something I'm currently interested in, but it's
something to look into if someone wants to use it in embedded
programming.
More information about the Digitalmars-d
mailing list