2014-11-09 131 views
0

我有一个问题在Windows上编译我的代码。C++,语法错误:缺少';'之前标识符'N0'

在基于Unix的系统都工作正常,但是当我编译它在Windows(目前与Visual Studio 2010和的快递),我收到以下错误:

错误253错误C2146:语法错误:缺少';'在标识符'N0'之前C:\ ghost ++ \ ghost \ ohconnect.h 45

错误254错误C4430:缺少类型说明符 - 假定为int。注:C++不支持default-int C:\ ghost ++ \ ghost \ ohconnect.h 45

错误255错误C4430:缺少类型说明符 - 假定为int。注意:C++不支持default-int C:\ ghost ++ \ ghost \ ohconnect.h 45

错误256错误C2146:语法错误:缺少';'在标识符'N'之前C:\ ghost ++ \ ghost \ ohconnect.h 46

错误257错误C4430:缺少类型说明符 - 假定为int。注:C++不支持default-int C:\ ghost ++ \ ghost \ ohconnect.h 46

依此类推。 我觉得这一切都与我的头文件,本身是由类连接到的WebSockets:

#ifndef OHConnect_H 
#define OHConnect_H 

// 
// OHCONNECT 
// 

class CTCPClient; 
class CBaseGame; 
class CCommandPacket; 
struct OHCHeader { 
    unsigned header_size; 
    bool fin; 
    bool mask; 
    enum opcode_type { 
    CONTINUTATION = 0x0, 
    TEXT_FRAME = 0x1, 
    BINARY_FRAME = 0x2, 
    CLOSE = 8, 
    PING = 9, 
    PONG = 0xa, 
    } opcode; 
    uint64_t N0; 
    uint64_t N; 
    uint8_t masking_key[4]; 
}; 

在我.cpp文件我用namespace std;和仅适用于Windows包括<string>。 但这一切都没有工作到目前为止。我并不想将整个文件放入问题中,因为它们实际上很长。 下面是完整的源代码: Headerfile Mainfile

我是怎么错在这里?

+0

'#include'ing'stdint.h'应该修复这些错误。 – 2014-11-09 07:27:39

回答

4

编译器不知道类型uint64_tuint8_t,添加:

#include <cstdint> 
2

还要注意,在枚举后面的逗号(定义PONG = 0xa后)仅在标准化C++ 11,以下在C99中所做的更改。较早的编译器或运行在1998/2003年以前的标准模式下的编译器可能会绊倒这一点。

+0

好点。没想过。 – 2014-11-09 07:39:26