views:

474

answers:

4

When compiling some working code on Fedora 11, I am getting this error:

/usr/include/c++/4.4.1/cstdarg:56: error: ‘::va_list’ has not been declared

I am using:

[doriad@davedesktop VTK]$ g++ --version
g++ (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)

Does anyone know what the problem could be?

Thanks,

Dave

+1  A: 

Bringing in the varadic macro set in g++ 4.4 has confusing and twisted semantics. You might get a better idea of what isn't happening by using g++ -E broken_code.cpp and looking at what the pre-processor is bringing in. There are a few dozen GNU C preprocessor directives that could prevent the ::va_list declaration from compiling as __gnuc_va_list which itself is of type __builtin_va_list

The junk code:

$cat junk.cpp
#include <cstdarg>

void foo(char *f, ...) { va_list va; va_start(va, va); }
int main(void) { foo("", "", ""); return 0; }
$ g++ junk.cpp
$ g++ --version
g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1

compiles and links (with warnings) with the relevant output of g++ -E junk.cpp being:

# 40 "/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 102 "/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 45 "/usr/include/c++/4.4/cstdarg" 2 3
# 54 "/usr/include/c++/4.4/cstdarg" 3
namespace std __attribute__ ((__visibility__ ("default"))) {

  using ::va_list;

}
msw
A: 

Hi David

I ran into the same issue on Ubuntu 9.10. Using GCC 4.4.1

Did you resolve this? If yes please help me out.

Thanks Vinit

Vinit
A: 

Still not resolved, even if i use stdarg.h.

Error just changes to va_list not declared in scope

Vinit
A: 

mee too. i'm using gcc 4.3

haryo