DMD hackers: pragma(address): Is this possible?

Johannes Pfau via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 25 08:29:53 PST 2014


Am Wed, 26 Nov 2014 00:28:52 +1100
schrieb "Daniel Murphy" <yebbliesnospam at gmail.com>:

> "Johannes Pfau"  wrote in message news:m51upj$u2v$1 at digitalmars.com...
> 
> > But does this really make sense? What makes a variable a variable?
> > For example the GCC backends has builtin support for extern,
> > static, const, manifest variables, but no way to specify an address
> > for an extern variable. Is there a reason for this?
> 
> Makes sense to me.   I image gcc backends don't natively support this 
> because it's equivalent to casting to a pointer and dereferencing.
> 
> Do we really need it with ref return and force-inline?
> 
> pragma(always_inline)
> ref ubyte PORTB() @property { return *cast(ubyte*)0x1000; }
> 
> That should also result in optimal asm, right? 
> 

Is taking addresses on properties still undefined? Or how exactly is it
defined? Anyway, &PORTB returns the address of the PORTB function
which is a small annoyance.


More information about the Digitalmars-d mailing list