Jump to content

Recommended Posts

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

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
14 hours ago, Stefan Glienke said:

Funny that you name the topic dynamic array not working when in fact you are declaring a const :classic_biggrin:

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×