DIP56 - inlining
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Tue Feb 3 21:51:29 PST 2015
On Wed, 04 Feb 2015 05:24:18 +0000, Orvid King wrote:
> Yes, but @attribute isn't defined when compiling with DMD, resulting in
> the need for some fun with version statements.
exactly one module, say, for example, `gcccompat.d`:
module gcccompat;
version(GNU) {
public import gcc.attribute;
} else {
private struct Attribute(A...) { A args; }
auto attribute(A...) (A args)
if (A.length > 0 && is(A[0] == string))
{ return Attribute!A(args); }
}
@attribute("forceinline") int test () { return 42; }
// wow, this works in DMD and LDC!
that's it. only one module, which can be easily added to any project. no
need to modify the compiler in any way.
> @attribute also has the
> limitation of it being a UDA, so it can't be used for things like branch
> hinting.
how `@compiler(inline, never)` can be used for branch hinting? oh, on the
second thought i don't want to see that syntax.
> I meant to include it in DIP 72, but forgot about that aspect
> of it; but I'd hope with DIP 72 to be able to allow @compiler attributes
> on statements, and, potentially, on expressions as well.
it still looks like UDA, it *can* be completely substituted by one UDA
with string arguments, it adds hacks and special rules to the compiler.
no wander Walter says "no" for it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150204/f7385311/attachment.sig>
More information about the Digitalmars-d
mailing list