【发布时间】:2014-06-10 13:20:04
【问题描述】:
我包含 cstdarg 并收到以下错误:
在“{”标记之前应为“=”、“,”、“;”、“asm”或“属性”
错误发生在以下行:
using ::va_list;
这是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
并且在这个文件中调用了 va_list:
#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;
}
【问题讨论】:
-
请提供一个MCVE 来证明您的问题。我敢打赌,这不是标题的错。
-
我正在编写一个包含 stdarg.h 的代码,然后 cstdargh 包含在 stdarg.h 中,当我进入时它给了我这个错误:make nitro gcc -c -o libnitro.o libnitro.c -g -Wall 包含在 /usr/include/c++/4.6.3/tr1/stdarg.h:32:0 中的文件中,来自 libnitro.c:3:/usr/include/c++/4.6.3/ cstdarg:55:1: 错误: 未知类型名称'namespace' /usr/include/c++/4.6.3/cstdarg:56:1: 错误: 预期'=', ',', ';', 'asm' 或'{' 标记之前的'属性' make: *** [libnitro.o] 错误 1
-
如果有用的附加信息,请在帖子中添加信息,而不是作为评论发布
-
你可以编写和编译得到这个错误的最小文件是多少?
-
你确定你不应该做
using namespace std;你所做的是声明你的代码在std命名空间中
标签: c++