473,511 Members | 10,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

storing variable arguments for future use

Hi,

I'm trying to implement delayed function execution,
similar to OpenGL's display lists. It looks something
like this:

beginList ();
fcn1 ();
fcn2 ();
Nov 14 '05 #1
4 1930
matevz bradac <ma*****@email.si> spoke thus:
When execList() is called, fcnToCall (numArgs, ...) should
be executed. The problem is, how do I store variable args
for future use? I know they're all long ints, so this should
be somehow helpful, but I can't figure it out. Do I have to
remember/copy the stack and is this possible in C, or must it
be done in assembly?


Have you looked at the functions in <stdarg.h>? They sound like
they'd help you a lot.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #2
"matevz bradac" <ma*****@email.si> wrote in message
news:cc**************************@posting.google.c om...
[snip]
When execList() is called, fcnToCall (numArgs, ...) should
be executed. The problem is, how do I store variable args
for future use? I know they're all long ints, so this should
be somehow helpful, but I can't figure it out. Do I have to
remember/copy the stack and is this possible in C, or must it
be done in assembly?


Assembly is probably the only way to do exactly what you describe,
unfortunately. Using the functions in <stdarg.h>, you could store a
suitably-sized array of the longs (when creating the function list), but
that wouldn't help much as there's no way in standard C to construct the
call to the variadic function.
Nov 14 '05 #3

In article <c5************@ID-149533.news.uni-berlin.de>, "Alex" <me@privacy.net> writes:
"matevz bradac" <ma*****@email.si> wrote in message
news:cc**************************@posting.google.c om...
[snip]
When execList() is called, fcnToCall (numArgs, ...) should
be executed. The problem is, how do I store variable args
for future use?


Assembly is probably the only way to do exactly what you describe,
unfortunately. Using the functions in <stdarg.h>, you could store a
suitably-sized array of the longs (when creating the function list), but
that wouldn't help much as there's no way in standard C to construct the
call to the variadic function.


I couldn't tell from the OP's description, but this might be another
case where the problem can be solved by implementing the real function
as a non-variadic one with a variadic wrapper. That is:

int fcnToCallV(long numArgs, va_list Args);

int fcnToCall(long numArgs, ...)
{
va_list Args;
int Ret;

va_start(Args, numArgs);
Ret = fcnToCallV(numArgs, Args);
va_end(Args);

return Ret;
}

(The OP didn't mention a return type for these functions, so I assumed
int.)

Then the OP's call-list system stores a call to fcnToCall as one to
fcnToCallV, by doing the va_start before storing it and the va_end
when processing the list, after the call returns.

--
Michael Wojcik mi************@microfocus.com

The movie culminated with a bit of everything. -- Jeremy Stephens
Nov 14 '05 #4
This is exactly what I want. I was hoping there's an easy
way of, well, memcpy()-ing the stack, and then passing it
to some function... -> assembly it will have to be.

Thanks,
matevz

"Alex" <me@privacy.net> wrote in message news:<c5************@ID-149533.news.uni-berlin.de>...
Assembly is probably the only way to do exactly what you describe,
unfortunately. Using the functions in <stdarg.h>, you could store a
suitably-sized array of the longs (when creating the function list), but
that wouldn't help much as there's no way in standard C to construct the
call to the variadic function.

Nov 14 '05 #5

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

Similar topics

2
1756
by: Francisco | last post by:
I have this problem: I have a database with information about games, and users are able to vote for them. Everytime a user votes for a game I store the unique game name into a session variable (an...
5
411
by: matevz bradac | last post by:
Hi, I'm trying to implement delayed function execution, similar to OpenGL's display lists. It looks something like this: beginList (); fcn1 (); fcn2 ();
4
13554
by: Augustus S.F.X Van Dusen | last post by:
I have recently come across the following construction: #define P_VAR(output, string, args...) \ fprintf (output, "This is "string"\n", ##args) which can be invoked as follows: int x = 1,...
14
5809
by: Luiz Antonio Gomes Pican?o | last post by:
How i can store a variable length data in file ? I want to do it using pure C, without existing databases. I'm thinking to use pages to store data. Anyone has idea for the file format ? I...
23
19133
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
2
2475
by: prasanthag | last post by:
Hi, I am a newbie to this group. I have a problem in handling the variable arguments passed to a function. My requirement is like this. I have 2 functions say, void funcX(int i, int j);...
3
2498
by: prasanthag | last post by:
Hi, I am a newbie to this group. I have a problem in handling the variable arguments passed to a function. My requirement is like this. I have 2 functions say, void funcX(int i, int j);...
8
1990
by: Fredrik Tolf | last post by:
I've been trying to get the string formatting operator (%) to work with more arguments than the format string requires, but I can find no way to do that. For example: '10' Traceback (most...
3
2247
by: Seth Gecko | last post by:
Hi I am working with generic lists of various objects and a control dealing with these lists. For instance: A parent form holds: dim Walls as List(Of wall) dim Segments as List(Of segment) ...
0
7245
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,...
0
7427
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...
0
7512
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...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
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...
0
4741
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...
0
3227
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...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.