Connecting Tech Pros Worldwide Help | Site Map

va_start and references

  #1  
Old July 22nd, 2005, 07:06 AM
John Harrison
Guest
 
Posts: n/a
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


  #2  
Old July 22nd, 2005, 07:06 AM
Pete Becker
Guest
 
Posts: n/a

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)
  #3  
Old July 22nd, 2005, 07:06 AM
John Harrison
Guest
 
Posts: n/a

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



  #4  
Old July 22nd, 2005, 07:07 AM
red floyd
Guest
 
Posts: n/a

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>
  #5  
Old July 22nd, 2005, 07:07 AM
John Harrison
Guest
 
Posts: n/a

re: va_start and references


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

Why?

john


  #6  
Old July 22nd, 2005, 07:08 AM
red floyd
Guest
 
Posts: n/a

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.
  #7  
Old July 22nd, 2005, 07:08 AM
Ron Natalie
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
() obsoleted?! Zeljko Vrba answers 21 November 14th, 2005 08:36 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 07:46 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 03:55 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 5 November 14th, 2005 12:36 PM