Connecting Tech Pros Worldwide Forums | Help | Site Map

va_start and references

John Harrison
Guest
 
Posts: n/a
#1: Jul 22 '05
Is the following code OK?

#include <stdarg.h>

void func(const X& x)
{
va_list args;
va_start(args, x);
funcv(x, args);
va_end(args);
}

void funcv(const X& x, va_list args)
{
// ...
}

In other words is it OK to use va_start on an parameter that is a reference?
I can't see anything that says it isn't, nor can I see why it shouldn't work
from looking at the definition of va_start in my compiler (VC++ 7). But I
get memory access errors in funcv, which only go away when I change the type
of the parameter to func from const X& to X.

john



Pete Becker
Guest
 
Posts: n/a
#2: Jul 22 '05

re: va_start and references


John Harrison wrote:[color=blue]
>
> In other words is it OK to use va_start on an parameter that is a reference?[/color]

No. 18.7/3.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
John Harrison
Guest
 
Posts: n/a
#3: Jul 22 '05

re: va_start and references



"Pete Becker" <petebecker@acm.org> wrote in message
news:40202077.21BBE3CC@acm.org...[color=blue]
> John Harrison wrote:[color=green]
> >
> > In other words is it OK to use va_start on an parameter that is a[/color][/color]
reference?[color=blue]
>
> No. 18.7/3.
>
> --
>
> Pete Becker
> Dinkumware, Ltd. (http://www.dinkumware.com)[/color]

OK thanks, I'd of found that reference if va_start had been in the index of
the standard.

john



red floyd
Guest
 
Posts: n/a
#4: Jul 22 '05

re: va_start and references


John Harrison wrote:[color=blue]
> "Pete Becker" <petebecker@acm.org> wrote in message
> news:40202077.21BBE3CC@acm.org...
>[color=green]
>>John Harrison wrote:
>>[color=darkred]
>>>In other words is it OK to use va_start on an parameter that is a[/color][/color]
>
> reference?
>[color=green]
>>No. 18.7/3.
>>
>>--
>>
>>Pete Becker
>>Dinkumware, Ltd. (http://www.dinkumware.com)[/color]
>
>
> OK thanks, I'd of found that reference if va_start had been in the index of
> the standard.
>
> john[/color]


Also, try using <cstdarg> instead of <stdarg.h>
John Harrison
Guest
 
Posts: n/a
#5: Jul 22 '05

re: va_start and references


>[color=blue]
>
> Also, try using <cstdarg> instead of <stdarg.h>[/color]

Why?

john


red floyd
Guest
 
Posts: n/a
#6: Jul 22 '05

re: va_start and references


John Harrison wrote:[color=blue][color=green]
>>
>>Also, try using <cstdarg> instead of <stdarg.h>[/color]
>
>[/color]

It was my impression that the <XXX.h> C90 headers were deprecated in
favor of the <cXXX> headers in C++98.
Ron Natalie
Guest
 
Posts: n/a
#7: Jul 22 '05

re: va_start and references



"red floyd" <no.spam@here.dude> wrote in message news:ma9Ub.20105$NF5.2927@newssvr27.news.prodigy.c om...[color=blue]
> John Harrison wrote:[color=green][color=darkred]
> >>
> >>Also, try using <cstdarg> instead of <stdarg.h>[/color]
> >
> >[/color]
>
> It was my impression that the <XXX.h> C90 headers were deprecated in
> favor of the <cXXX> headers in C++98.[/color]

Deprecation has no real meaning however.

Closed Thread


Similar C / C++ bytes