473,785 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FormatMessage and va_list args

Hi,

I have a function that has a variable no of arguments
(note! function shortened)

myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'.

How can I correctly pass this all since the code above does not work.
Nov 17 '05 #1
4 2705
> myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'. How can I correctly pass this all since the code above does not work.

What do you mean by "does not work".
What is the behavior? Does not compile? Crashes?

--
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Nov 17 '05 #2
It works fine. But I think you may need to read FormatMessage's
documentation again.

Nov 17 '05 #3
"Mihai N." <nm************ **@yahoo.com> wrote in message
news:Xn******** **********@207. 46.248.16...
myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'.

How can I correctly pass this all since the code above does not work.

What do you mean by "does not work".
What is the behavior? Does not compile? Crashes?


OK,

Solved.

I assumed that %s would be recognized as well. It should be %1 :)

Nov 17 '05 #4
"Mihai N." <nm************ **@yahoo.com> wrote in message
news:Xn******** **********@207. 46.248.16...
myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'.

How can I correctly pass this all since the code above does not work.

What do you mean by "does not work".
What is the behavior? Does not compile? Crashes?


garbled output.
Nov 17 '05 #5

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

Similar topics

2
4724
by: Andrej Prsa | last post by:
Hi! If I declare two functions like this: int execute_command (char *name, ...) { va_list args; va_start (args, name); my_func (1, args);
7
4845
by: Jon | last post by:
Is it possible to modify an argument of a va_list and then pass the modified va_list to other functions? void c_fun1(int, va_list args) { int *firstIntPointer = &(va_arg(args, int)); *firstIntPointer = 2; // a new value }
11
3075
by: thierrydollar | last post by:
Hi, I have written a very simple program using variable arguments calls and I get strange things that I cannot explain. I have one function (add) that displays two parameters. It works well when I call it directly. Now I have a second function (set) that also calls add. But this doesn't
12
1869
by: Volte | last post by:
Hey, wondering if there is a va_list equivalent in Javascript. Well, actually, I know that there is, but I don't know if its user... applicable. va_list in C/++ anyhow is a way of being able to pass in any number of arguments at the end of a function, I'll show an example: Header: void addLine(int, const char*, ...); cpp:
1
9476
by: skillzero | last post by:
Is there a portable way to pass a va_list as a parameter to another function taking a variable argument list? I have a function that takes a printf-like format string and I'd like to use something like %V to pass in another format string and a va_list to allow nesting. It happens to work on my compiler, but I wasn't sure if it's portable to use va_list's as parameters to a variable argument function because va_list isn't always just a...
4
19248
by: Tor Rustad | last post by:
I have a C program, where I control the error behavior according to context: /* some error handlers */ static void on_error_log (MYSQL *mysql, const char *msg, ...); .... static void on_error_exit (MYSQL *mysql, const char *msg, ...); /* the error function */ static void (*error_fatal) (MYSQL *mysql, const char *msg, ...) =
8
2777
by: Fred | last post by:
I've got following program encapsuled fscanf, however, it doesn't work. I'm sure that the content format in "a.txt" is OK, the content would be correctly read if using fscanf directly, what's wrong with my program? Thanks for help! int vsscanf( FILE* fp, const char *fmt, ... ) { va_list arglist; va_start( arglist, fmt );
5
4668
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On Jun 3, 3:23 am, Jesse Ziser <d...@spam.diewrote: The relevant paragraph from the Standard is: ---- Begin Quote ---- The type declared is va_list which is an object type suitable for holding information needed by the macros
2
4238
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
There are tons of examples of how to call FormatMessage from C# on the internet, but none of these pass insertions strings to the FormatMessage. Is there an example of how this should work? My DllImport currently looks like this. This doesn't seem correct to me since the 7th parameter is a va_list *. It would be nice to be able to pass in the insertion strings this way however, right now I will take anything that works.
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
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...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
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
6744
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
5397
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...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.