期望' = ',',',';',' asm '或' __attribute__ '在'{'标记之
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token when I have using ::va_list;
我包括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;
}
你应该用g++
而不是gcc
编译你的c++代码。
此外,大多数用户(和程序)期望以.c
结尾的文件(如libnitro.c
)使用C语言,而不是c++语言。对于c++源代码,您应该将文件命名为libnitro.cpp
或libnitro.cc
。
相关文章:
- 从类型std::函数传递变量失败,尽管调用方期望的类型完全相同
- 一元*运算符的操作数是否期望一个 prvalue
- 使用C++获取程序的 ASM
- 在 c++ 中使用 x86 DIV 的这个 asm 块有什么用?
- 什么 /可以/ 你从一个函数返回. 并期望它在到达时还活着?
- 如何将子类作为函数的参数传递给期望基类,然后将该对象传递到指向这些抽象类对象的指针向量中?
- g++ -O3 为 loop 创建了奇怪的指令 - 两个具有相同 asm 的版本
- 根据实例化点期望不同的类型
- gtest 期望无序元素与自定义比较器/匹配器一起使用
- Extern "C"错误在'int'之前'asm'或'__attribute__'
- 了解 C/C++ 中 Windows / MSVC 的一些反调试内联 asm
- C++ 期望":"(冒号)的构造函数
- 尝试使用 x86 asm SSSE3 将大端转换为小端序
- 如何使用"asm volatile"编写 btr 指令
- objdump 不显示机器代码,但显示 ASM
- 未使用的 asm() 在不受支持的体系结构上的行为
- 内联asm编译器屏障(内存阻塞器)是算作外部函数,还是算作静态函数调用
- std::mutex::lock() 产生奇怪(和不必要的)ASM 代码
- 将 std::vector::d ata 传递给函数期望类型**(双指针)
- 期望' = ',',',';',' asm '或' __attribute__ '在'{'标记之