c ++错误3错误C2159:指定了多个存储类

时间:2014-10-05 06:57:47

标签: c++

我使用Visual Studio 2008编译我的源代码,它只是一直给我这个错误:

c++ Error   3   error C2159: more than one storage class specified

我度过了不眠之夜,无法弄清楚问题所在。

C ++代码

    #pragma once

#define SET_EXCEPTION(x) PyErr_SetString(PyExc_RuntimeError, #x)

bool PyTuple_GetString(PyObject* poArgs, int pos, char** ret);
bool PyTuple_GetInteger(PyObject* poArgs, int pos, unsigned char* ret);
bool PyTuple_GetInteger(PyObject* poArgs, int pos, int* ret);
bool PyTuple_GetInteger(PyObject* poArgs, int pos, WORD* ret);
bool PyTuple_GetByte(PyObject* poArgs, int pos, unsigned char* ret);
bool PyTuple_GetUnsignedInteger(PyObject* poArgs, int pos, unsigned int* ret);
bool PyTuple_GetLong(PyObject* poArgs, int pos, long* ret);
bool PyTuple_GetUnsignedLong(PyObject* poArgs, int pos, unsigned long* ret);
bool PyTuple_GetFloat(PyObject* poArgs, int pos, float* ret);
bool PyTuple_GetDouble(PyObject* poArgs, int pos, double* ret);
bool PyTuple_GetObject(PyObject* poArgs, int pos, PyObject** ret);
bool PyTuple_GetBoolean(PyObject* poArgs, int pos, bool* ret);

bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs);
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, bool* pisRet);
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, long * plRetValue);

bool PyCallClassMemberFunc_ByPyString(PyObject* poClass, PyObject* poFuncName, PyObject* poArgs);
bool PyCallClassMemberFunc(PyObject* poClass, PyObject* poFunc, PyObject* poArgs);

PyObject * Py_BuildException(const char * c_pszErr = NULL, ...);
PyObject * Py_BadArgument();
PyObject * Py_BuildNone();
PyObject * Py_BuildEmptyTuple();

static auto &&PyTuple_GetDWORD = PyTuple_GetUnsignedLong;

编译器指出错误在第31行,即

static auto &&PyTuple_GetDWORD = PyTuple_GetUnsignedLong;

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:2)

关键字auto在C ++ 11之前具有不同的含义。这意味着变量是一个自动变量,其范围是本地的。在C ++ 11中,其含义更改为“推断变量的类型”。

由于VS 2008不支持C ++ 11构造,因此它以旧的含义解释auto。当这样解释时,

static auto &&PyTuple_GetDWORD = PyTuple_GetUnsignedLong;

没有意义,因为变量不能同时为staticauto

相关文章:Goal of C's "auto" keyword