-

Changes

Jump to: navigation, search

Machine Dependencies

134 bytes removed, 18:17, 30 July 2017
no edit summary
compilers.
;char
:is at least 8 bits
;short
:is at least 16 bits
;long
:is at least 32 bits
;int
:is the same as either short or long
;float
:is at least 32 bits
;double
:is at least as wide as float
Because of the variable width of an int, it is recom-mended recommended that short or long be used wherever possible in
preference to int. The exception to this is where a quantity
is required to correspond to the natural word size of the
this problem other than to avoid code which depends on a
particular ordering. In particular you should avoid writing
out whole structures to a file (via _�f_�w_�r_�i_�t_�e<strong>fwrite</strong>()) unless the
file is only to be read by the same program then deleted.
Different compilers use different amounts of padding between
structure members, though this can be modified via the#pragma pack(n) construct.
== Predefined Macros ==
One technique through which machine unavoidable machine
dependencies may be managed is the predefined macros pro-vided provided by each compiler to identify the target processor and
operating system (if any). These are defined by the compiler
driver and may be tested with conditional compilation
table 2. These can be used as shown in the example in fig .
___________________________________________{||+<strong>_Macro__Defined_for</strong>||-|i8051 || 8051 processor family |-|i8086 || 8086 processor family |-|i8096 || 8096 processor family |-|z80 || Z80 processor and derivatives |-|m68000|| 68000 processor family |-|m6800 || 6801, 68HC11 and 6301 processors|-|m6809 || 6809 processor |-|DOS || MS-DOS and PC-DOS |-|CPM || CP/M-80 and CP/M-86 |-|TOS || Atari ST |-|}
|_M�_a�_c�_r�_o�_______________D�_e�_f�_i�_n�_e�_d�__f�_o�_r�_____________�|;Table 2. Predefined Macros
| i8051 8051 processor family |
| i8086 8086 processor family | | i8096 8096 processor family | | z80 Z80 processor and derivatives | | m68000 68000 processor family | | m6800 6801, 68HC11 and 6301 processors| | m6809 6809 processor | | DOS MS-DOS and PC-DOS | | CPM CP/M-80 and CP/M-86 | | TOS Atari ST | |___________________________________________�|  Table 2. Predefined Macros   #if DOS char * filename = "c:file"; #endif /* DOS */ #if CPM char * filename = "0:B:afile"; #endif /* CPM */

Navigation menu