V
Vaclav Haisman
Hi,
I have the following code. I wonder if it is valid to pass std::va_list
around by reference to const like this:
//-----8<--------
#include <cstdarg>
#include <cstdio>
void foo (char const * fmt, std::va_list const & l)
{
std::vprintf(fmt, l);
}
void bar (char const * fmt, ...)
{
std::va_list l;
va_start (l, fmt);
foo (fmt, l);
va_end (l);
}
int main ()
{
bar ("%s", "test\n");
}
//-----8<--------
This code produces the following error with GCC on FreeBSD/AMD64, but
compiles and works well on 32bit host:
va_test.cxx: In function 'void foo(const char*, const __va_list_tag (&)[1])':
va_test.cxx:7: error: invalid conversion from 'const __va_list_tag*' to
'__va_list_tag*'
va_test.cxx:7: error: initializing argument 2 of 'int vprintf(const char*,
__va_list_tag*)'
I have the following code. I wonder if it is valid to pass std::va_list
around by reference to const like this:
//-----8<--------
#include <cstdarg>
#include <cstdio>
void foo (char const * fmt, std::va_list const & l)
{
std::vprintf(fmt, l);
}
void bar (char const * fmt, ...)
{
std::va_list l;
va_start (l, fmt);
foo (fmt, l);
va_end (l);
}
int main ()
{
bar ("%s", "test\n");
}
//-----8<--------
This code produces the following error with GCC on FreeBSD/AMD64, but
compiles and works well on 32bit host:
va_test.cxx: In function 'void foo(const char*, const __va_list_tag (&)[1])':
va_test.cxx:7: error: invalid conversion from 'const __va_list_tag*' to
'__va_list_tag*'
va_test.cxx:7: error: initializing argument 2 of 'int vprintf(const char*,
__va_list_tag*)'