17.05.2015 Views

TMS34010 C Compiler - Al Kossow's Bitsavers

TMS34010 C Compiler - Al Kossow's Bitsavers

TMS34010 C Compiler - Al Kossow's Bitsavers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>TMS34010</strong> C Language - Data Types<br />

4.2 <strong>TMS34010</strong> C Data Types<br />

K&R 4.0 - Equivalent Types<br />

• The char data type is signed. A separate type, unsigned char, is supported.<br />

• long and int are functionally equivalent types. Either of these types can<br />

be declared unsigned.<br />

• double and long double are functionally equivalent types.<br />

• The properties of enum types are identical to those of unsigned int.<br />

K&R 4.0 - Additional Types<br />

• An additional type, called void, can be used to declare a function that<br />

returns no value. The compiler checks that functions declared as void<br />

do not return values and that they are not used in expressions. Functions<br />

are the only type of objects that can be declared void. .<br />

• The compiler also supports a type that is a pointer to void (void *).<br />

An object of type void * can be converted to and from a pointer to an<br />

object of any other type without explicit conversions (casts). However,<br />

such a pointer cannot be used indirectly to access the object that it<br />

points to without a conversion. For example,<br />

void *p, *malloc();<br />

char *c;<br />

int i;<br />

p<br />

p<br />

p<br />

c<br />

i<br />

K&R 4.0 - Derived Types<br />

i<br />

malloc();<br />

c;<br />

&i;<br />

malloc();<br />

*p;<br />

*(int *)p;<br />

/*<br />

/*<br />

/*<br />

/*<br />

/*<br />

/*<br />

Legal */<br />

Legal, no cast needed<br />

Legal, no cast needed<br />

Legal, no cast needed<br />

Illegal, dereferencing<br />

void pointer<br />

Legal, dereferencing<br />

casted void pointer<br />

*/<br />

*/<br />

*/<br />

<strong>TMS34010</strong> C allows any type declaration to have up to six derived types.<br />

Constructions such as pointer to, array of, and function returning can be<br />

combined and applied a maximum of six times.<br />

For example:<br />

int (* (*n[] []) () ) ();<br />

translates as:<br />

1 } an array of<br />

2} arrays of<br />

3) pointers to<br />

·4) functions returning<br />

5) pointers to<br />

6) functions returning integers<br />

It has six derived types, which is the maximum allowed.<br />

*/<br />

*/<br />

4-4

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

Saved successfully!

Ooh no, something went wrong!