Zamrony P. Juhara via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am So., 26. März 2023, 00:05:
> Suppose I have > > unit mytest; > > interface > > const > MY_VALUE = 1; > MY_INT_VALUE: integer = 1; > > implementation > end. > > and second unit > > unit mytest2; > > interface > > uses mytest; > > const > // this is legal > MY_VALUE = mytest.MY_VALUE; > > // this causes illegal expression > // MY_INT_VALUE = mytest.MY_INT_VALUE; > // MY_INT_VALUE : integer = mytest.MY_INT_VALUE; > > implementation > end. > > > Is there workaround to redeclare typed constant in other unit so that I > don't need to duplicate code? > Typed constants are essentially variables and you can't redeclare variables. Only way you might do that (which I do not recommend because it opens it's own can of worms) is to declare the original variable as "public" and to import it in the other unit using "external". Regards, Sven >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal