Annotations 如何在D语言中使用用户定义的属性?

Annotations 如何在D语言中使用用户定义的属性?,annotations,d,Annotations,D,根据该计划,我有以下计划: void main() { @(3) int var; } 但它只是不编译: test.d(2): identifier expected after @, not ( test.d(2): basic type expected, not 3 test.d(2): no identifier for declarator int test.d(2): semicolon expected, not '3' test.d(2): found ')'

根据该计划,我有以下计划:

void main() {
    @(3)
    int var;
}
但它只是不编译:

test.d(2): identifier expected after @, not (
test.d(2): basic type expected, not 3
test.d(2): no identifier for declarator int
test.d(2): semicolon expected, not '3'
test.d(2): found ')' when expecting ';' following statement

此功能是在几个版本之前添加的。因此,请检查编译器版本,看看是否需要更新。最新版本是v2.064.2

如果您使用的是dmd,请运行
dmd-v
。 如果您使用的是ldc2,请运行
ldc2-version
。 GDC也会有类似的方法