leniad 0 Posted March 1, 2023 I've written this piece of code ... type def_dip_value=record dip_val:word; dip_name:string; end; tdef_dip=record mask:word; name:string; number:byte; dip:array of def_dip_value; end; ... Everything goes fine, but when I try to declare some const like this... const my_dip:array [0..1] of tdef_dip=( (mask:$f;name:'name1';number:16;dip:[(dip_val:$2;dip_name:'name1'),(dip_val:$5;dip_name:'name2')]), (mask:$10;name:'name2';number:2;dip:[(dip_val:$10;dip_name:'name3'),(dip_val:$0;dip_name:'name4')]) ); ... Cannot compile, delphi fails with error 'Undeclared identifier: 'dip_val' I've tested the same code on Free Pascal and works fine, so, what I'm doing wrong? Any idea? Share this post Link to post
Mike Torrettinni 198 Posted March 1, 2023 If you want to initialize const then, I think, it has to be a constant expressions, so dip can't be dynamic array. So, something like this: type def_dip_value=record dip_val:word; dip_name:string; end; tdef_dip=record mask:word; name:string; number:byte; dip:array [0..1] of def_dip_value; // if you want to initialize as const expression end; const my_dip:array [0..1] of tdef_dip=( (mask:$f;name:'name1';number:16;dip:((dip_val:$2;dip_name:'name1'),(dip_val:$5;dip_name:'name2'))), // NO SQUARE BRACKETS! (mask:$10;name:'name2';number:2;dip:((dip_val:$10;dip_name:'name3'),(dip_val:$0;dip_name:'name4'))) // NO SQUARE BRACKETS! ); Try and see if this helps. Share this post Link to post
Stefan Glienke 2002 Posted March 1, 2023 Funny that you name the topic dynamic array not working when in fact you are declaring a const Anyhow this is a known bug at least since 2018 - see https://quality.embarcadero.com/browse/RSP-19816 Share this post Link to post
Lars Fosdal 1791 Posted March 2, 2023 14 hours ago, Stefan Glienke said: Funny that you name the topic dynamic array not working when in fact you are declaring a const Anyhow this is a known bug at least since 2018 - see https://quality.embarcadero.com/browse/RSP-19816 I wonder why I can't access that issue! And... now it works. Make sure to re-enter your creds after time-out 😛 Share this post Link to post