Recent

Author Topic: Is there a function/operator in FPC that returns the offset of a field ?  (Read 5882 times)

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Is there a function/operator in FPC that returns the offset of a field ?
« Reply #15 on: November 13, 2018, 11:47:51 pm »
Ok, so create a writeable constant of your record and then reference it the same way but subtract the desired field from the
base of the constant and you have your offset..

 But I think you would rather have the compiler just give you a number is my guess or you are just being cantankerous.


The only true wisdom is knowing you know nothing

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: Is there a function/operator in FPC that returns the offset of a field ?
« Reply #16 on: November 13, 2018, 11:55:05 pm »
Ok, so create a writeable constant of your record and then reference it the same way but subtract the desired field from the
base of the constant and you have your offset..

 But I think you would rather have the compiler just give you a number is my guess or you are just being cantankerous.
No, I am not being cantankerous. <chuckle>.  Yes, I would much rather have the compiler tell me the offset because it already has it in its symbol table(s), just like high and low for an array. The compiler has the information and, that information is often useful to declare other types that adjust automatically to changes in the types they depend on (as for loop index ranges change if they are coded using high and low, for instance.)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018