On 08/03/14 17:14, Iain Buclaw via Digitalmars-d wrote: > On 2 August 2014 14:54, Artur Skawina via Digitalmars-d >> But I'm not sure if exposing `attribute` like that would be >> a good idea (until now I was always using a static import, so >> name clashes were not a problem); I'd probably rename it to >> `__attribute__`. > > This can be done, we can deprecate attribute in favour of > __attribute__ and add new enums for shortcut paths to access the > internal attributes. > > One way could be as above, alternatively if name clashing is a > problem, then we can always prefix with GNU_ > > --- > enum GNU_forceinline = __attribute__("forceinline"); > /* etc... */ > > auto GNU_target(A...)(A args) > if(A.length > 0 && is(A[0] == string)) > { > return __attribute__("target", args); > } > --- > > Then in user code: > > --- > import gcc.attribute; > > @GNU_forceinline int foobar(); > @GNU_target("sse3") float4 mySSE3Func(); > ---
No; the advantage of using these magic UDA is that they don't need to be vendor-specific. IOW one can define "inline" as the GDC magic attribute, or nothing. Maybe even some other compiler can support it. And the source code remains portable. @GNU_forceinline @LLVM_forceinline @DM_forceinline @SDC_forceinline int foobar(); // ... artur