11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

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.

Library FunctionsVA_START, VA_ARG, VA_ENDSynopsis#include void va_start (va_list ap, parmN)type va_arg (ap, type)void va_end (va_list ap)DescriptionThese macros are provided to give access in a portable way to parameters to a function represented ina prototype by the ellipsis symbol (...), where type and number of arguments supplied to the functionare not known at compile time.The rightmost parameter to the function (shown as parmN) plays an important role in thesemacros, as it is the starting point for access to further parameters. In a function taking variable numbersof arguments, a variable of type va_list should be declared, then the macro va_start() invokedwith that variable and the name of parmN. This will initialize the variable to allow subsequent callsof the macro va_arg() to access successive parameters.Each call to va_arg() requires two arguments; the variable previously defined and a type namewhich is the type that the next parameter is expected to be. Note that any arguments thus accessedwill have been widened by the default conventions to int, unsigned int or double. For example if acharacter argument has been passed, it should be accessed by va_arg(ap, int) since the char willhave been widened to int.An example is given below of a function taking one integer parameter, followed by a numberof other parameters. In this example the function expects the subsequent parameters to be pointersto char, but note that the compiler is not aware of this, and it is the programmers responsibility toensure that correct arguments are supplied.Example224#include #include voidpf (int a, ...){

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

Saved successfully!

Ooh no, something went wrong!