According to Orlando Llanes:
I noticed a quirk with Borland Pascal, and I was wondering if it was present in GPC, when you define a record structure as follows:
TYPE MyRec = RECORD CASE Integer OF 0 : (SomeVar : Integer; SomeVar2 : Integer); 1 : AnotherVar : ARRAY[ 1..2 ] OF Integer; END; END;
This is not a quirk but a variant record which is even part of the ISO standard. (Hmmm ... so maybe it "must" be a quirk?;-) (BTW, you have one superfluous `END' in the above.)
Supposedly, you want to tell the compiler to use SomeVar, or AnotherVar as if they were overlapping. An Integer is 16 bits in BP, with that in mind, BP would report 8 when you use SizeOf( MyRec ), logically it should be 4. By overlapping, I mean like a type cast. Is there a way to do this in GPC like C apparently does?
GPC accepts this, just like BP or any other Pascal compiler does.
Greetings,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [971005] maintainer GNU Pascal [971001] - http://home.pages.de/~gnu-pascal/ [971005]