VA_LIST
Posted: Wed Nov 23, 2005 6:32 am
Hi everybody.
i tried yesterday to make a function with a va_list.
this is the function prototype:
if the last uint8_t is DRAW_TRANSPARENT (0x2), then the function request one parameter more. i tried to get it with this peace of code here:
but however this one didn't work.
what made i wrong?
could you help me? thx
thx for help.
i tried yesterday to make a function with a va_list.
this is the function prototype:
Code: Select all
void DrawBitmap (GUIBitmap *, int32_t, int32_t, uint8_t, ...);
Code: Select all
#typedef unsigned long uint32_t;
void DrawBitmap(GUIBitmap *_bmp, int32_t _x, int32_t _y, uint8_t _mode, ...)
{
va_list args;
va_start(args, _mode);
uint32_t transp = va_arg(args, uint32_t); //needed only if _mode == DRAW_TRANSPARENT
va_end(args);
};
what made i wrong?
could you help me? thx
thx for help.
Code: Select all
#ifndef STDARG_H
#define STDARG_H
typedef unsigned char *va_list;
#define STACKITEM int
#define va_start(AP,LASTARG) \
( AP = (( va_list ) & ( LASTARG ) + VA_SIZE( LASTARG )))
#define va_arg(AP,TYPE) \
(AP+=__va_rounded_size(TYPE),*((TYPE *)(AP-__va_rounded_size(TYPE))))
#define __va_rounded_size(TYPE) \
(((sizeof(TYPE)+sizeof(int)-1)/sizeof(int))*sizeof(int))
#define VA_SIZE(TYPE) \
((sizeof(TYPE)+sizeof(STACKITEM)-1)&~(sizeof(STACKITEM)-1))
#define va_end(AP) \
( AP = (void *)(0) )
#endif