我有一个问题:我的代码在 CentOS g++ 中运行良好,但是当我在 Visual Studio 2008 中编译它们时,Visual Studio 告诉我如下错误:
1.c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(19) : error C2144: syntax error : '__w64 unsigned int' should be preceded by '}'
2.error C2143: syntax error : missing '}' before 'namespace'.
我的文件编码是UTF-8。如果我将它们全部更改为 Unicode,我更改了 Unicode 中的一些错误文件,它仍然存在如上所述的错误。
下面是一些源代码:
#ifndef ENRC_CODE_DEFS_H
#define ENRC_CODE_DEFS_H
enum ENReturnCode
{
ENRC_SUCCESS = 0,
ENRC_FAILED,
ENRC_NODATA,
ENRC_CONFIG_NOT_AVAILABLE,
ENRC_INVALID_SUBSCRIBE_ID,
ENRC_INVALID_SUBSCRIBE_CONDITION,
ENRC_INVALID_SUBSCRIBER,
ENRC_INVALID_PARAMETER,
ENRC_THREAD_RUNNING,
ENRC_SUBSCRIBE_LIST_EMPTY,
ENRC_OUT_OF_MEMORY // 10
}
e:\my_code\cppcommon\include\errordefs.h(5) : 错误 C2143: 语法错误 : 缺少 ';'在“枚举[标签]”之前
下一个:
#ifndef EN_SMS_SRC_TAO2CPP_H_
#define EN_SMS_SRC_TAO2CPP_H_
#include "SystemMonitorMasterServiceC.h"
#include "SystemMonitorSlaveServiceC.h"
#include "CommonDefs.h"
#include "SystemMonitorServiceDataDefs.h"
namespace EN
{
namespace SMS
{
template < typename _Ty, typename _Cy>
inline
void Tao2Cpp_Enum(_Ty taoValue, _Cy &cppValue)
{
cppValue = (_Cy)taoValue;
}
错误 C2143:语法错误:“命名空间”之前缺少“}”
有很多像上面这样的错误。
谢谢。我花了一些时间让它易于阅读。
最佳答案
您需要在枚举声明中使用分号:
enum ENReturnCode
{
...
};
关于C++ 代码可以在 CentOS g++ 中编译,但不能在 Visual studio 2008 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8669217/