C++ 代码可以在 CentOS g++ 中编译,但不能在 Visual studio 2008 中编译

标签 c++ windows linux visual-c++ encoding

我有一个问题:我的代码在 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/

相关文章:

c++ - 什么是 undefined reference / Unresolved external symbol 错误,我该如何解决?

windows - 通过 LLVM 或 GCC 以 WinRT 为目标

检查 VirtualAlloc 是否返回了 VirtualAddress

python - Windows 没有将命令行参数传递给从 shell 执行的 Python 程序

linux - Bash echo 在字符串外带有 $ 字符

c++ - 在 C++ 中使用最小优先级队列和 key 更新的最简单方法

c++ - 高于 FullHD 分辨率的帧丢失。MediaFoundation 中是否提供 AVI 解压缩器转换过滤器?

c++ - Boost.Geometry 多边形点赋值

linux - udev 规则不适用于 ThinkPad X200 dock

c - 在 C 中覆盖 _init 函数,它有多安全?