Host introspection: Difference between revisions

→‎{{header|Lua}}: added Lua solution
(Example added in PDP-10 assembly (MACRO-10/TOPS-20).)
(→‎{{header|Lua}}: added Lua solution)
Line 648:
Endianness: little-endian
</pre>
 
=={{header|Lua}}==
Pure/native Lua can't do this (and essentially doesn't care). However, Lua is often used in a scripting environment, where such issues may be important, and any needed support would be expected to be provided by the host or some other external library. Here using ffi:
<lang lua>ffi = require("ffi")
print("size of int (in bytes): " .. ffi.sizeof(ffi.new("int")))
print("size of pointer (in bytes): " .. ffi.sizeof(ffi.new("int*")))
print((ffi.abi("le") and "little" or "big") .. " endian")</lang>
{{out}}
<pre>size of int (in bytes): 4
size of pointer (in bytes): 8
little endian</pre>
 
=={{header|M2000 Interpreter}}==
Anonymous user