va-list

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...

C varargs - va_copy issues

I'm writing a function in C that takes a variable number of arguments. size_t myprintf(char *fmt, ...); So far, so good. I've decided it's best to do things the Right Way™ and make a version that takes variable arguments, and another version that takes a va_list. size_t myprintf(char *fmt, ...); size_t myvprintf(char *fmt, va_list ar...

x64 va_list in Visual Studio 2005

I have a class non-static member function, and it has variable arguments, I'm compiling on Visual Studio 2005, with the 64-bit runtime, on 64-bit Windows. void Class::Foo(void* ptr,...) { va_list args; va_start(args,ptr); float f=va_arg(args,float); va_end(args) } I'm expecting a float, I pass a float to the function. ...

Passing one va_list as a parameter to another

I'm creating an application using the fastcgi library, and their method of printing is a little verbose. I'm trying to wrap their fprintf function in my own method: I would like to turn FCGX_FPrintF(out, char* fmt, ...); into write(char* strFormat, ...); I've found the magic of va_list but can't find an easy way to pass va_l...

va_list has not been declared

When compiling some working code on Fedora 11, I am getting this error: /usr/include/c++/4.4.1/cstdarg:56: error: ‘::va_list’ has not been declared I am using: [doriad@davedesktop VTK]$ g++ --version g++ (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2) Does anyone know what the problem could be? Thanks, Dave ...

NSString stringWithFormat swizzled to allow missing format numbered args

Based on this SO question asked a few hours ago, I have decided to implement a swizzled method that will allow me to take a formatted NSString as the format arg into stringWithFormat, and have it not break when omitting one of the numbered arg references (%1$@, %2$@) I have it working, but this is the first copy, and seeing as this meth...

va_arg returning the wrong argument

With the following code va_arg is returning garbage for the second and third pass through vProcessType. // va_list_test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <tchar.h> #include <cstdarg> #include <windows.h> void processList(LPTSTR str, ...); void vProcessList(LPTSTR str, va_list ar...

Use variadic functions in C89 without passing number of arguments or a final argument?

Let's say I have a variadic function foo(int tmp, ...), when calling foo function I need to know how many arguments there are. I'm aware of two ways of finding out how many arguments there are: Use a final argument when calling foo, like -1, so your function call will be like this: foo(tmp, 1, 2, 9, -1) and when you are inside foo and...

va_list create dynamically.

All: I have faced such a problem. I have a function void foo(int cnt, va_list ap); I need to use it, and but requirement is quite strict, number of va_list vary and it will change during run-time. What I would like to do is: create a va_list (which expects char*) form QList<Contact*> where Contact is a defined class class Cont...

Matching va_list types between compilers.

I have a project that consists of a bunch of dynamically loaded modules. Originally, everything was always built with MSVC 2003, but lately I've been working on getting it to work with GCC. Everything has been going pretty smoothly, except for one problem. For 64-bit code, GCC and MSVC don't agree about what a va_list is. For 32-bit,...

How do I get a formatted NSString from format and va_list?

I'm developing a static library that will be distributed to other developers, who may need debug statements. So I have several levels of logging. In order to avoid constant appearance of if(loggingLevelCurrentlySet >= loggingLevelWantedForThisInstance){ NSLog(@"log this"); } I created a set of logging function wrappers. A simp...