2014-10-05 982 views
0

我使用Visual Studio 2008來編譯我的源代碼,它只是不斷給我這個錯誤:ç錯誤C2159 ++錯誤:一個以上的存儲類指定

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

我度過了不眠之夜它和couldn不知道問題出在哪裏。

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; 

任何幫助將非常感謝!

+4

我不認爲Visual Studio 2008的支持右值引用或'auto'。您需要VS2012或更高版本才能使用C++ 11功能。 – 2014-10-05 07:01:09

+0

本源碼由VS2008在與我相同業務的其他競爭對手編譯。請考慮一下SLN項目的以下幾行: Microsoft Visual Studio解決方案文件格式版本10.00 #Visual Studio 2008 – D3XT3R 2014-10-05 07:04:26

+1

根據這個VS2010有右值和自動支持,但絕對不是2008:http:// msdn .microsoft.com/en-us/library/hh567368.aspx – 2014-10-05 07:08:20

回答

2

關鍵字auto在C++ 11之前有不同的含義。這意味着一個變量是一個自動變量,它的範圍是局部的。在C++ 11中,其含義改變爲意味着「推斷變量的類型」。

由於VS 2008不支持C++ 11構造,因此它解釋了auto的舊含義。當解釋那樣,

static auto &&PyTuple_GetDWORD = PyTuple_GetUnsignedLong; 

沒有意義,因爲變量不能staticauto在同一時間。

相關崗位:Goal of C's "auto" keyword

+0

這意味着我必須升級到Visual Studio 2010才能使源按預期工作? – D3XT3R 2014-10-05 07:10:15

+0

請承擔我的愚蠢,我對C++相當陌生。 – D3XT3R 2014-10-05 07:15:25

+0

@ D3XT3R,我不認爲VS 2010會支持C++ 11。你將不得不跳轉到VS 2012.看看http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx。 – 2014-10-05 07:16:32