Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-05

record initialization

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jürgen Hestermann

when I try to initialize a record as in

----------------------------------------
var X : record
             A : Sizeint;
             B : boolean;
             C : Sizeint;
             D : boolean;
             E : Sizeint;
             F : boolean;
             G : Sizeint;
             H : boolean;
             end = (A : 0;
                    B : false;
                    C : 0;
                    D : boolean;
                    E : 0;
                    F : false;
                    G : 0;
                    H : false);
----------------------------------------

then this works as expected.
When omitting some entries from the end it works too:

----------------------------------------
var X : record
             A : Sizeint;
             B : boolean;
             C : Sizeint;
             D : boolean;
             E : Sizeint;
             F : boolean;
             G : Sizeint;
             H : boolean;
             end = (A : 0;
                    B : false;
                    C : 0;
                    D : boolean;
                    E : 0);
----------------------------------------

I only get a warning, that"Some fields coming after "E" weren't initialized".

But when I leave out variables in the middle or at the beginning as in:

----------------------------------------
var X : record
             A : Sizeint;
             B : boolean;
             C : Sizeint;
             D : boolean;
             E : Sizeint;
             F : boolean;
             G : Sizeint;
             H : boolean;
             end = (B : false;
                    C : 0;
                    D : boolean;
                    H : false);
----------------------------------------

then I get an error "Some fields coming before "B" weren't initialized" and it does not compile.

I found no words about this restriction in http://www.freepascal.org/docs-html/ref/refse23.html Shouldn't it appear there?
It took me quite a while to find out why it did not compile because omitting from the end works so why does it not work when omitting from the beginning (or in the middle)?

Reply by email