On Friday, 24 April 2026 23:57:16 BST Martin Frb via fpc-devel wrote:
> Btw, any idea where the compiler stores the target pointer size?

I believe what you are looking for is voidpointertype.size - it is the correct 
target-aware pointer size in the FPC compiler.                
                                                                                
                    
- sizeof(pint) — reflects the host compiler's pointer size (wrong for cross-
compilation)          
- voidpointertype.size — reflects the target pointer size (set during 
psystem.pas initialisation based on the target CPU)                             
                                             
                                                                                
                    
Interestingly, that means dbgdwarf.pas:3317 has a bug with 
tai_const.create_8bit(sizeof(pint)) for the DWARF address_size field.           
                  
                                               
The code should read:                                                           
        
  
  inc(G_ByteCounter, voidpointertype.size)                                      
                    
                                               
voidpointertype is declared in symdef.pas and is always available once the 
system unit types are initialised. You can see psystem.pas:206 uses case 
voidpointertype.size of to decide which integer types map to pointer-sized 
integers — it's the established idiom for this.

I'll test a bit later and open a MR in my initial investigation is correct.


Regards
  Graeme




_______________________________________________
fpc-devel maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to