Reputation: 21
I am including cstdarg and get the following error:
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token"
The error occurs on the following line:
using ::va_list;
Here is the content of cstdarg:
#pragma GCC system_header
#include </usr/include/c++/4.6.3/x86_64-linux-gnu/bits/c++config.h>
#include <stdarg.h>
#ifndef _GLIBCXX_CSTDARG
#define _GLIBCXX_CSTDARG 1
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef va_end
#define va_end(ap) va_end (ap)
#endif
namespace std
{
using ::va_list; I get the error here!
} // namespace std
#endif
and va_list was called in this file :
#include <fcntl.h>
#include <unistd.h>
#include </usr/include/c++/4.6.3/tr1/stdarg.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include </usr/include/x86_64-linux-gnu/bits/errno.h>
#include "string.h"
#include "libnitro.h"
#include "nitro.h"
#define KVM_NODE "/dev/kvm"
int kvm_fd;
int kvm_vmfd;
struct nitro_vcpus vcpus;
int kvm_ioctl(int type, ...)
{
int ret;
void *arg;
va_list ap;
va_start(ap, type);
arg = va_arg(ap, void *);
va_end(ap);
ret = ioctl(kvm_fd, type, arg);
if (ret == -1)
ret = -errno;
return ret;
}
int kvm_vm_ioctl(int type, ...)
{
int ret;
void *arg;
va_list ap;
va_start(ap, type);
arg = va_arg(ap, void *);
va_end(ap);
ret = ioctl(kvm_vmfd, type, arg);
if (ret == -1)
ret = -errno;
return ret;
}
int kvm_vcpu_ioctl(int vcpu_fd,int type, ...){
int ret;`
` void *arg;`
` va_list ap;`
va_start(ap, type);
arg = va_arg(ap, void *);
va_end(ap);
ret = ioctl(vcpu_fd, type, arg);
if (ret == -1)
ret = -errno;
return ret;
}
int kvm_ioctl(int type, ...)
{
int ret;
void *arg;
va_list ap;
va_start(ap, type);
arg = va_arg(ap, void *);
va_end(ap);
ret = ioctl(kvm_fd, type, arg);
if (ret == -1)
ret = -errno;
return ret;
}
Upvotes: 1
Views: 3587
Reputation: 81986
You should compile your c++ code with g++
not gcc
.
Additionally, most users (and programs) expect that files that end in .c
, (like libnitro.c
) use the C language, not the C++ language. For c++ source code, you should name your file libnitro.cpp
or libnitro.cc
.
Upvotes: 1