"Johannes Pfau"  wrote in message news:m522gv$1rav$1...@digitalmars.com...

Good idea, this works and results in equal ASM. A minor drawback is
that this emits an additional function (even with always inline), but
that's a problem that also occurs in other contexts and I've got a
workaround for that.

Awesome.

Inlining in GDC right now only works across modules when templates are
used. Templating the PORTB property doesn't work (PORTB()() is not an
lvalue when taking the address &PORTB).
So I'll probably have to implement cross-module inlining then.

Will it be cross-module inlined if it's an alias to a templated function instantation?

module a;

ref ubyte IOREG(size_t addr)() { return *cast(ubyte*)addr; }

alias PORTA = IOREG!(0x10000);
alias PORTB = IOREG!(0x10001);

==========

module b;
import a;

void main()
{
   auto x = &PORTA;
   PORTB |= 7;
}

Reply via email to