va-arg

Populating a va_list

Is there a way to create a va_list from scratch? I'm trying to call a function that takes a va_list as a parameter: func(void **entry, int num_args, va_list args, char *key); ...from a function that doesn't take a variable number of arguments. The only way I can think of is to create an intermediary function that takes varargs and t...

How to convert a Variable argument function into a macro?

Hello, I have a variable argument function which prints error messages in my application,whose code is given below. void error(char *format,...) { va_list args; printf("Error: "); va_start(args, format); vfprintf(stderr, format, args); va_end(args); printf("\n"); abort(); } This function error()is used in e...

Passing on va_arg twice to a function result in same value.

I'm trying to use va_arg to make a generic factory function in my GUI library. When passing va_arg twice in the same function they pass on the same value instead of two different: GUIObject* factory(enumGUIType type, GUIObject* parent, ...){ va_list vl; va_start(vl, parent); ... label->SetPosition(va_arg(vl, int), va_arg(vl,...

Objective-C va_list and selectors

Is it possible to use @selector and performSelector: (or similar) with methods using variable arguments list? I'm writing a class that can be assigned a delegate to override the default behavior. In the presence of a delegate select method calls made on an instance of that class will be forward to the same corresponding delegate method,...

How to get address of va_arg?

I hack some old C API and i got a compile error with the following code: void OP_Exec( OP* op , ... ) { int i; va_list vl; va_start(vl,op); for( i = 0; i < op->param_count; ++i ) { switch( op->param_type[i] ) { case OP_PCHAR: op->param_buffer[i] = va_arg(vl,char*); // ok i...

problem with va_arg()

I want to wirte a function with variable arguments in this way: static void configElement(U32 localFaultId, char* name, U32 report, U32 localId, U32 detectTime, U32 ceaseTime,...) { U32 i = 0; U32 tmp...

va_list with unknown type names - only the byte size is known!

Hello Folks! I'm having a C programming question: I want to write a function with variable argument lists, where the specific types of each argument is not know - only its size in bytes. That means, if I want to get an int-Parameter, I (somewhere before) define: There will be a parameter with sizeof( int ), that is handled with a callba...

va-args not resolving correctly

I have the following function: void Register(Data* _pData, uint32 _Line, const char* _pFile, ...) { va_list Args; va_start(Args, _pFile); for(uint i = 0;i m_NumFloats; ++i) { _pData->m_Floats[i] = va_arg(Args, fp32); } va_end(Args); } Which is called by the macro: #define REG(_Name, ...)\ {\ if(s_##_Name##_...

Can stdcall have a variable arguments?

As far as I know, only the caller-clean-stack convention can use variable arguments. By the way, the WinApi StringCchPrintfW is declared like this.(I removed the SAL) _inline HRESULT _stdcall StringCchPrintfW( STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat, ... ); Can stdcall have a variable arguments eithe...

Count number of parameters in C variable argument method call

When using va_start(), va_arg() and va_end() to read parameters passed to a method, is there a way to count how many arguments there are? According to the man page if you call va_arg() too many times you get "random errors": If there is no next argument, or if type is not compatible with the type of the actual next argument (as ...