09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C Language Portability <strong>XENIX</strong> Programming<br />

The loader used may also place a restriction on the number of unique characters in C<br />

external symbols.<br />

Symbols unique in the first six characters are unique to most C language processors.<br />

On some non-<strong>XENIX</strong> C implementations, uppercase and lowercase letters are not<br />

distinct in identifiers.<br />

Register Variables<br />

The number and type of register variables in a function depends on the machine<br />

hardware and the compiler. Excess and invalid register declarations are treated as<br />

nonregister declarations and should not cause a portability problem. Typically, up to<br />

three register declarations are significant, and they must be of type int, char, or<br />

pointer. While other machines and compilers may support declarations such as<br />

register unsigned short<br />

this should not be relied on.<br />

Since the compiler ignores excess variables of register type, the most important register<br />

type variables should be declared first. Thus, if any are ignored, they will be the least<br />

important ones.<br />

Type Conversion<br />

The C language has some rules for implicit type conversion; it also allows explicit type<br />

conversions by type casting. The most com mon portability problem in implicit type<br />

conversion is unexpected sign extension. This is a potential problem whenever<br />

something of type char is compared with an int.<br />

For example<br />

char c;<br />

if(c = = Ox80)<br />

will never evaluate true on a machine that sign extends since c is sign extended before<br />

the comparison with Ox80, an int.<br />

The only safe comparison between char type and an int is the following:<br />

A-8<br />

char c;<br />

if(c = = 'x')

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!