17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

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

Built-in Functions<br />

}<br />

void main()<br />

{<br />

int total;<br />

total = foo(2,4,6,9,10,2);<br />

}<br />

Example Files:<br />

None<br />

Also See: va_start( ) , va_end( ) , va_arg( )<br />

offsetof( ) offsetofbit( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

value = offsetof(stype, field);<br />

value = offsetofbit(stype, field);<br />

stype is a structure type name.<br />

Field is a field from the above structure<br />

An 8 bit byte<br />

These functions return an offset into a structure for the indicated field.<br />

offsetof returns the offset in bytes and offsetofbit returns the offset in bits.<br />

All devices<br />

#INCLUDE <br />

Examples:<br />

struct time_structure {<br />

int hour, min, sec;<br />

int zone : 4;<br />

intl daylight_savings;<br />

}<br />

x = offsetof(time_structure, sec);<br />

// x will be 2<br />

x = offsetofbit(time_structure, sec);<br />

// x will be 16<br />

x = offsetof (time_structure,<br />

daylight_savings);<br />

// x will be 3<br />

x = offsetofbit(time_structure,<br />

daylight_savings);<br />

// x will be 28<br />

Example Files:<br />

Also See:<br />

None<br />

None<br />

225

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

Saved successfully!

Ooh no, something went wrong!