GDC UDA Attributes (was 'checkedint call removal')

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 3 08:14:44 PDT 2014


On 2 August 2014 14:54, Artur Skawina via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> +
> +enum noinline = attribute("noinline");
> +enum inline = attribute("forceinline");
> +enum flatten = attribute("flatten");
>
> 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();
---


Regards
Iain.


More information about the Digitalmars-d mailing list