How oder where is the addres size for the current compiler target defined?
mfg Steve

Mailing lists / fpc-devel / 2014-11
10 messages · 5 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
How oder where is the addres size for the current compiler target defined?
mfg Steve
Steve Hildebrandt wrote on ma, 10 nov 2014:
How oder where is the addres size for the current compiler target defined?
See the last three entries in table G.2. at
http://www.freepascal.org/docs-html/prog/progap7.html
Alternatively, you can use
{$if sizeof(pointer)=8}
<64 bit pointers>
{$elseif sizeof(pointer)=4}
<32 bit pointer>
etc...Jonas
I think he means in the compiler, but for the target the compiler is not compiling for.
For a cross-compiler, sizeof(pointer) sizeof(pointer on target arch)
Michael.
Steve Hildebrandt wrote on ma, 10 nov 2014: See the last three entries in table G.2. at…
Sry I should have mentioned I'm currently working on the compiler and I'm not to sure if I can use OS_ADDR for RTTI generation.
Steve
Steve Hildebrandt wrote on ma, 10 nov 2014:
Sry I should have mentioned I'm currently working on the compiler and I'm not to sure if I can use OS_ADDR for RTTI generation.
If you want a tcgsize, use def_cgsize(voidcodepointertype) for references to code and def_cgsize(voidpointertype) for references to data.
If you want to create an initialised data entry, use tai_const.Create_nil_codeptr/Create_nil_dataptr for nil code/data pointers, tai_const.Create_int_codeptr/Create_int_dataptr for code/data pointers with an absolute value known at compile time, or in case you have a symbol name, use
tai_const.createname/createname_global with either AT_FUNCTION or AT_DATA depending on whether it's code or data (and depending on whether it's a global symbol or not, which you can determine via tabstractnormalvarsym.globalasmsym, or via "po_public in procdef.procoptions" for a procdef)
Jonas
Thanks def_cgsize(voidcodepointertype) was what I was looking for.
Steve
I think he means in the compiler, but for the target the compiler is not compiling for.…
On Mon, Nov 10, 2014 at 4:07 PM, Michael Van Canneyt <
So wait, the following code:
{$if sizeof(pointer)=8} Code1 {$elseif sizeof(pointer)=4} Code2 {$endif}will evaluate Code1 for a FPC compiler that is itself compiled as a x86_64 (64bit) linux program but itself targets Win32 (32bit)? If so, this is highly counterintuitive (and i don't see the usefulness of it).
You cut away the important part of the original message: "I think he means in the compiler". I.e., this is inside the compiler source code itself.
Jonas
On Mon, Nov 10, 2014 at 4:07 PM, Michael Van Canneyt < So wait, the following code: {$if…
Am 19.11.2014 16:15 schrieb "Kostas Michalopoulos" <
Michael's message wasn't meant as literal code. A compiler compiled for x86_64 will have sizeof(pointer)=8, but the pointer size of the target architecture (AFAIK called "aint" in the compiler, but I'm not sure currently) might be different from that, so inside the compiler One should know exactly which kind of Pointer one is talking about.
Regards,
Sven
Yes this is what i meant. I'd expect that the sizeof(pointer) to return the target architecture's pointer size, not the architecture of the compiler's own executable.