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.

different type than it returns,<br />

this function avoids the<br />

overhead of converting the<br />

parameters to a larger type.<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example<br />

Files:<br />

Also See:<br />

All devices<br />

Nothing<br />

int a=50, b=100;<br />

long int c;<br />

c = _mul(a, b);<br />

5000<br />

None<br />

None<br />

//c holds<br />

nargs( )<br />

Syntax: void foo(char * str, int count, ...)<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

The function can take variable parameters. The user can use stdarg<br />

library to create functions that take variable parameters.<br />

Function dependent.<br />

The stdarg library allows the user to create functions that supports<br />

variable arguments.<br />

The function that will accept a variable number of arguments must have<br />

at least one actual, known parameters, and it may have more. The<br />

number of arguments is often passed to the function in one of its actual<br />

parameters. If the variable-length argument list can involve more that<br />

one type, the type information is generally passed as well. Before<br />

processing can begin, the function creates a special argument pointer of<br />

type va_list.<br />

All devices<br />

#INCLUDE <br />

Examples:<br />

int foo(int num, ...)<br />

{<br />

int sum = 0;<br />

int i;<br />

va_list argptr; // create special argument pointer<br />

va_start(argptr,num); // initialize argptr<br />

for(i=0; i

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

Saved successfully!

Ooh no, something went wrong!