How do you initialise a const array of TGUID from Interface type data, in Delphi?

后端 未结 7 750
谎友^
谎友^ 2020-12-18 00:43

I want to initialise an array like this -

Const MyArray : Array[0..0] Of TGUID = (IInterface);

But it results in -

[DCC Err         


        
7条回答
  •  一整个雨季
    2020-12-18 01:38

    Here's a way I discovered using the fact that traditionally, consts are not really const in delphi. Requires a compiler switch to return to this behaviour (In D2007)

    {$J+}
    Const MyArray : Array[0..0] Of TGUID = (());
    {$J-}
    

    In initialization section -

    MyArray[0] := IInterface;
    

提交回复
热议问题