04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Language Extensions<br />

Example<br />

int Case_Ranges_0(int arg)<br />

{<br />

int aLocal;<br />

int bLocal =arg;<br />

switch (bLocal)<br />

{<br />

case 0 ... 10:<br />

aLocal= 1;<br />

break;<br />

case 11 ... 100:<br />

aLocal =2;<br />

break;<br />

default:<br />

aLocal=-1;<br />

}<br />

return aLocal;<br />

}<br />

3.7.4 Cast of a union<br />

A cast to a union type is similar to other casts, except that the type specified is a union<br />

type. You can specify the type either with a union tag or with a typedef name.<br />

Mode<br />

Supported in GNU mode for C90 and C99 only.<br />

Example<br />

typedef union<br />

{<br />

double d;<br />

int i;<br />

} foo_t;<br />

int Cast_to_Union_0(int a, double b)<br />

{<br />

}<br />

foo_t u;<br />

if (a>100)<br />

u = (foo_t) a ; // automatically equivalent to u.i=a;<br />

else<br />

u = (foo_t) b ; // automatically equivalent to u.d=b;<br />

return u.i;<br />

3-26 Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. <strong>ARM</strong> DUI 0348C<br />

Non-Confidential,<br />

ID101213

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

Saved successfully!

Ooh no, something went wrong!