assembly - C datatypes size after compilation -
the question follows: c programming language define how executables produced compilers should formatted in terms of data size types? better explain this, let's assume compile c source code file contains variable of type int called 'x'. compile source code executable , run it. during runtime memory location allocated 'x' 4 bytes wide , structured under 2's complement standard.
if run same compiled executable different machine same operating system , compatible cpu, have guarantee variable @ times 4 bytes wide in exact same format (meaning exact same bit footprint)? know c has variable data sizes elementary types , applies pre-compiled code. post-compiled code? if int translates assembler dword data type on 1 machine allocates 32 bits it, there guarantee take form of 32 bits on another? dword same across different cpus of same model?
i've assumed compilation process of establishing implementation details , 'setting in stone' exact size , internal formats of data types in-memory confirmation. also, apply c++ well?
below c level, compilers abide "application binary interface" (abbreviated abi; not mistake api). sets these details in stone. application binary interface defines size of types , representation of integers, among lot of other things, how parameters passed functions.
a single platform can support multiple abis. instance, on windows, have native abi, , can install cygwin, lets run programs abi closer linux one. however, assuming 2 different machines have support same abi, yes, sharing executables between them guaranteed work (assuming required libraries , such present) , guaranteed have compatible representation.
this same in principle c++.
Comments
Post a Comment