Definition: | integer i = machine_bits() |
Description: | machine_bits() is a function built-in to the interpreter. It indicates the architecture that the program is being executed on: 32 or 64 . |
Use machine_bits() when you want to execute different code depending
on which architecture the program is running on. Most applications do
not need to use machine_bits(), except perhaps to optimise a critical
inner loop, however the phix interpreter, for example, has to know
whether to generate 32 or 64 bit machine instructions.
The machine_word() function is very similar, yielding 4 or 8 for a 32 or 64 bit executable respectively. The call to machine_bits() costs nothing. It is optimized at compile-time into the appropriate integer value: 32 or 64. Further, no code whatsoever will be emitted for the comparison, else, and one of the two branches in the following. |
|
Example 1: |
if machine_bits()=32 then poke4(addr,{#55667788,#11223344}) else poke8(addr,#1122334455667788) end if |
Example 2: |
pokeN(addr,pszMsg,machine_word()) -- (poke a 4 or 8 byte pointer) |
Example 3: |
This routine is phix specific. For compatibility with OpenEuphoria the following can be used (copied from builtins\cffi.e):
--/* function machine_bits() ifdef BITS64 then return 64 elsedef return 32 end ifdef end function --*/ |
See Also: | platform, format directive |