On 12/06/2019 22:25, Simon Ameis wrote:

const
   MYRECORDCONST2: TMyRecord = (x: 5); //< compiles fine
   MYINTEGERCONST: Integer = 5;        //< defining integer const
   MYRECORDCONST1: TMyRecord = (x: MYINTEGERCONST); //< using constant is
no possible

For historical reasons, "MYINTEGERCONST: Integer = 5" does not declare a constant, but an initialised variable. To declare a constant, use

const
  MYINTEGERCONST = 5;

If you want to explicitly specify its type, you can use

const
  MYINTEGERCONST = Integer(5);


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to