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.
signature.asc
Description: PGP signature