473,795 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing varargs to another function

Hi,

I want to write a varargs function which then passes its parameters to
another varargs function. I have RTFFAQ:

http://www.eskimo.com/~scs/C-faq/q15.12.html

which says that the other function should accept a va_list pointer to do
this. However, I can't seem to get this answer working.

Would someone mind posting a simple example of how this can be done?

Many thanks in advance,
Ian
Nov 14 '05 #1
2 11902
begin followup to Ian Partridge:
Would someone mind posting a simple example of how this can be done?


http://www.google.at/search?q=exampl...va_list+va_arg

=>

http://www.qnx.com/developer/docs/mo.../v/va_arg.html

--
Für Google, Tux und GPL!
Nov 14 '05 #2
Ian Partridge <i.*********@DI ESPAM.uk.ibm.co m> wrote:
# Hi,
#
# I want to write a varargs function which then passes its parameters to
# another varargs function. I have RTFFAQ:

static void plover(int x,...) {va_list L; va_start(L,x); etc;}
static void plugh(int x,...) {va_list L; va_start(L,x); plover(x,L); etc;}

This won't work. You need a version of plover that accepts a va_list.

static void vplover(int x,va_list L) {...}
static void plover(int x,...) {va_list L; va_start(L,x); vplover(x,L);}
static void plugh(int x,...) {va_list L; va_start(L,x); vplover(x,L); etc;}

# which says that the other function should accept a va_list pointer to do
# this. However, I can't seem to get this answer working.
#
# Would someone mind posting a simple example of how this can be done?

--
Derk Gwen http://derkgwen.250free.com/html/index.html
One of the drawbacks of being a martyr is that you have to die.
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14954
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
58
10183
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
2
5239
by: Mike - EMAIL IGNORED | last post by:
Consider: #include <syslog.h> // Open syslog in constructor. void MyClass:: MyMemberFunction(...) {
9
4982
by: grid | last post by:
Hi, I have a function which takes a variable number of arguments.It then calls va_start macro to initialize the argument list.But here in my case I have a special builtin va_start provided by the compiler which I use for performance gains.Then the variable arguments are passed to another varargs function which then uses a builtin va_arg macro to get the arguments. Iam getting an error from the compiler in the called function when a local...
2
4128
by: Rick Anderson | last post by:
I want to store a "va_list" in a structure (which gets passed around from function to function). I cannot use the va_copy() routine to create a copy of the varargs (it looks like it uses stack memory). Has anyone written some portable code to create a copy of the varargs information, and subsequent routines to retrieve the varargs information? Thanks in advance! Rick
50
6506
by: Mikhail Teterin | last post by:
Hello! The sample program below is compiled fine by gcc (with -Wall), but rejected by Sun's SUNWspro compiler (version 6 update 2). The point of contention is, whether a value for one of the union's types can be passed to a function directly -- without creating a separate variable of the union type and assigning the appropriate field of it. Is gcc being too liberal, or is this behavior simply part of a newer
9
2414
by: Rob Hoelz | last post by:
Is there a way to pass the variable argument list from one function to another? For example: void my_func(const char *fmt, ...) { char str; snprintf(str, 255, fmt, ...); } I know that probably won't work, but you get my meaning.
13
4238
by: Tim H | last post by:
Goal: to provide the simplest call-site possible at the cost of upfront hackery. I have a function that essentially takes a variable list of arguments: func(const string &k0, unsigned long long v0, const string &k1, unsigned long long v1, etc) This is going to be called a LOT from code that is hand-written, so I really ant to simplify the job of calling this function.
6
29570
by: antianti | last post by:
Hello, I have a function that has a variable # of arguments of varying types. int foo(short a, ...) { va_list argp va_start(argp, a); ... va_end(argp);
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10167
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7544
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6784
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.