Sign in Join

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

Mailing lists / fpc-pascal / 2007-02

Re: Some features I use daily in FPC I hope

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Jason P Sage
Daniel Mantione wrote
This isn't true: * Cardinal: is always an unsigned 32-bit integer * Pointer: can be 32-bit or 64-bit depending on processor * Integer: is a signed 16-bit or 32-bit integer depending on compiler mode

And you are absolutely correct. I forget this because I have the FPC configuration set to always use the 32 bit sized integer.

As for Cardinal being only 32bit - that stinks because it's a major oversight on my part. Is there a data type equivalent to Cardinal for 64-bit? I mean - I tried to use a gambit of "processor size" independent variables for doing "low level" stuff - like pointer math.

Cardinal - Unsigned, can use write statements, can convert to and from text
- perfect. Is there anyway it could be made 64bit? Or Platform size independent variables could be made besides pointer?

Darn...this means code I thought was all nicely converted for 64 bit - is going to be useless. ...sigh...

Then what I was thinking was wrong. I hope someday there is a platform size based variable like pointer is for Cardinal and Integer.

---

Marc Santhoff wrote 7 lines
Since you're fiddling with low level stuff and I had a problem similar a while ago: Do you see a way of calculating the offset using types instead of variables? Using your example I would like to use something like: uMyCardinalOffset:=cardinal(rtMyRecord.saMyEmail);
Not quite - more like:
uMyCardinalOffset:=cardinal(rtMyRecord(nil^).saMyEmail;

I'n not sure I answered your question - and it is very clean mark - however, as the above states - I just got correct by Daniel on something that just impeded my ability to take my code to the 64 bit level without some major work.

I was mistakingly under the impression that Pointer, Integer, and Cardinal - would grow with the platform size like pointer does. This limits me as to what I can do for fancy pointer operations - as there isn't much in the way of converting a pointer to a platform sized unsigned integer safely on 64bit platform.

This is rather upsetting. My fault... but upsetting nonetheless.

I do hope I answered your question - I mean, if I understood your original question about getting the offset with types versus variables - I think the syntax I wrote above does what you are asking.

Best Regards All,
Jason P Sage

Marco van de Voort
to Jason P Sage
As for Cardinal being only 32bit - that stinks because it's a major oversight on my part. Is there a data type equivalent to Cardinal for 64-bit? I mean - I tried to use a gambit of "processor size" independent variables for doing "low level" stuff - like pointer math.

qword is 64-bit

ptrint and ptruint are processor sized types (32-bit on 32-bit and 64-bit on 64-bit) for pointer math.