On Sun, 24 Feb 2013 13:03:26 -0500, jerro <[email protected]> wrote:
extern(C) int bar();
@bar() void foo(){}
//pragma(msg, __traits(getAttributes, foo));
void main()
{
auto x = __traits(getAttributes, foo)[0];
}
is compilable and runnable when linker knows where bar() is.
So this is actually supposed to work? The documentation says:
User Defined Attributes (UDA) are compile time expressions that can be
attached to a declaration.
I guess the documentation is wrong or at least unclear in that case.
It sort of makes sense. Remember, these are compile-time entities. If
nobody every looks at them, there is no need for the compiler to either.
For example, this compiles:
template foo(T)
{
enum foo = new T;
}
But if you ever try to use it, the compiler will complain.
-Steve