The warning I get is as follows:
warning: implicit declaration of function `__va_start'
The offending code snippet follows:
#include <stdarg.h> /* For va_list etc */
#include <string.h>
#include <stdio.h>
int printf_Look_Alike_Function(const char * format, ...)
{
int PrLen;
char MyStr[1024];
PrLen = vsprintf(MyStr, format, (char *) __va_start(format));
... varied code to use MyStr as desired
return(PrLen);
}
For the record (although it should not make any difference) I am using
XCode 1.5 under 10.3.9 on a G5 (Tiger is too slow on a G5 to suit me
even with Spotlight turned off so I am stuck with XCode 1.5 for now).
Thanks in advance to anyone who can point me in the right direction.
PCR
--
The __va_start looks very much like an internal function, probably of a
certain C library (GNU libc maybe?), that you as a user shouldn't use.
Here's some example of vfprintf(), I think your vsprintf should be
similar:
int some_func(char *format, ...)
{
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
return bla;
}
Basically you can use the list as a va_list, and you have to wrap its
use between va_start and va_end.
HTH
(btw, the stdarg header is alright)
I'd just like to add that the double-underscore (at the beginning of
__va_start) should be a hint to you that the code is using something it
shouldn't be using.
The C and C++ language specs reserve all double-underscore symbols for
internal use by the compiler and it's standard libraries. If you use
one, you should be aware that it is internal, proprietary, not portable,
and subject to change without notice in future releases of the compiler.
(Similarly, you should never use a double-underscore in any function you
write, because it might conflict with an internal compiler-symbol now or
in the future.)
-- David
>Can anybody tell me where __va_start is declared in the Unix headers
>used by XCode
It isn't. __va_start (as indicated by the leading "___") is internal
to a compiler suite. It won't work on any other compiler suite
(except by chance).
>I am in the process of porting all my CW code over to XCode
There's your problem.
Just guessing: you probably want to use the standard va_start() macro.
--
dhs spe...@panix.com
Thanks for the tip. The va_start call looks like a much better way
of doing things than what I have been doing all this time. I'm not sure
what past example the __va_start usage originally came from
but I found it at least 10-15 years ago and have been using it all
this time simply because it worked and worked well to accomplish
the task I needed. It was probably somebody's CW or MPW shortcut
that really needs to be put into the proper form for continued use.
I will give the va_start() function a try right now. If you hear
no additional reply from me you can assume that it worked OK.
Thanks again.
PCR
--