Connecting Tech Pros Worldwide Help | Site Map

va_start and references

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 06:06 AM
John Harrison
Guest
 
Posts: n/a
Default va_start and references

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, 06:06 AM
Pete Becker
Guest
 
Posts: n/a
Default 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, 06:06 AM
John Harrison
Guest
 
Posts: n/a
Default 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, 06:07 AM
red floyd
Guest
 
Posts: n/a
Default 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, 06:07 AM
John Harrison
Guest
 
Posts: n/a
Default Re: va_start and references

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

Why?

john


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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.