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]
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?;-)
<grin> I wish there was something that overlaps instead of it increasing the size :-/ I guess the only way around it is Type-casting.
(BTW, you have one superfluous `END' in the above.)
Oops :}
GPC accepts this, just like BP or any other Pascal compiler does.
I mean does GPC add to the size of the record? Or are all the cases one size? For example, in my SomeVar example, would GPC treat it as 4 elements? Or 2?
See ya! Orlando Llanes
"Hey, we all did the drug thing, we all did the money thing, and eventually you find out that none of that stuff fixes anything, and we have nowhere else to go except to evolve spiritually and intellectually" -- Meredith Brooks
"Look out fo' flyeeng feet" O__/ a010111t@bc.seflin.org /|____. O <__. /> / \ ____________|_________ http://ourworld.compuserve.com/homepages/Monkey414