Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / November 2006



Tip: Looking for answers? Try searching our database.

Where Is __va_start Declared?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil Rogers - 28 Nov 2006 06:35 GMT
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 - 28 Nov 2006 08:00 GMT
> The warning I get is as follows:
>
[quoted text clipped - 18 lines]
>
> }

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. - 28 Nov 2006 16:01 GMT
>> The warning I get is as follows:
>>
[quoted text clipped - 35 lines]
> Basically you can use the list as a va_list, and you have to wrap its
> use between va_start and va_end.

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
Phil Rogers - 28 Nov 2006 20:17 GMT
> > The warning I get is as follows:
> >
[quoted text clipped - 39 lines]
>
> (btw, the stdarg header is alright)

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

--
David Spencer - 28 Nov 2006 16:41 GMT
>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.

Signature

dhs spencer@panix.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.