Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where Is __va_start Declared?

127 views
Skip to first unread message

Phil Rogers

unread,
Nov 28, 2006, 1:35:42 AM11/28/06
to
Can anybody tell me where __va_start is declared in the Unix headers
used by XCode and which of the more common higher level headers
would be the most likely ones to bring in this declaration? I am in the
process of porting all my CW code over to XCode (yeah, yeah, I know
I am a few years late) and have just finished getting all my libraries
to build properly. I had thought that I had the -Wmost flag turned on
all the time but when I tried to piece together my first test app based
on these libs I found that-Wmost was not on after all. When I did turn
it on I began to get warnings on the following simple code segment at
several places where it is used and so far have not been able to locate
the header containing the __va_start declaration (I believe it is a
macro from what I have gleaned from a Google search).

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

--

Ulrich Hobelmann

unread,
Nov 28, 2006, 3:00:14 AM11/28/06
to
Phil Rogers wrote:
> 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);
>
> }

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)

David C.

unread,
Nov 28, 2006, 11:01:49 AM11/28/06
to

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

David Spencer

unread,
Nov 28, 2006, 11:41:54 AM11/28/06
to
Phil Rogers <pro...@nospam.com> writes:

>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

Phil Rogers

unread,
Nov 28, 2006, 3:17:16 PM11/28/06
to

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

--

0 new messages