2013-01-24 52 views
0

这个问题很大程度上与我的previoustwo问题有关。包括socket.io-client-cpp和提升到Windows 8 C++应用程序

我已经构建并在我的项目中包含了boost 1.51。

在我Socket.IO接口文件(pch.h一起),这是我包括顺序:

#include <wrl.h> 
#include <dwrite_1.h> 
#include <wincodec.h> 
#include <agile.h> 
#include "types.h" 
#include <cstdint> 
#include <stdint.h> 
#include <climits> 
#include <cstdlib> 
#include "boost/cstdint.hpp" 
#include "boost/asio.hpp" 
#include "boost/bind.hpp" 
#include <sio_client_handler.hpp> 
#include "boost/thread.hpp" 

当我编译我的代码,我得到下面的输出(仅前几行):

错误1个错误C2039: 'int_least8_t':不是 '`全局命名空间'”(SocketIO.cpp)C的成员:\程序文件(86)\微软的Visual Studio 11.0 \ VC \ include \ cstdint

错误2错误C2873:'int_least8_ t':符号不能用于使用声明(SocketIO.cpp)c:\ program files(x86)\ microsoft visual studio 11.0 \ vc \ include \ cstdint

错误3错误C2039:'int_least16_t':is不是“全局命名空间”(SocketIO.cpp)的成员c:\ program files(x86)\ microsoft visual studio 11.0 \ vc \ include \ cstdint

错误4错误C2873:'int_least16_t':symbol can not be在使用声明(SocketIO.cpp)中使用c:\​​ program files(x86)\ microsoft visual studio 11.0 \ vc \ include \ cstdint

有超过100个以上错误。

我正在使用Microsoft Visual Studio 2012 Express C++,并且一直未能想出或找到解决方案。

回答

0

我最终创建了自己的socket.io客户端实现。这是一个与工作有关的项目,所以我需要获得公开发布的权限。

0

您正在C库头文件中混合使用C++库头文件(这是不好的风格),特别是您在<stdint.h>之前包含<cstdint>。 IIRC,Visual C++的<cstdint>只包含<stdint.h>命名空间标准。这意味着,你#include<stdint.h>不会做任何事情(因为包括守卫)。此外,int_least8_t等将只在名称空间标准中驻留而不是,而不在全局名称空间中。

我不太确定在VS 2012中这是否正确,但您可以通过深入探索<cstdint>来检查。

在任何情况下,请参考命名空间std中的那些类型,因为这是它们应该在其中的标准兼容命名空间。如果您经常使用它们(如它似乎),请使用指令将它们导入到任何命名空间中正在工作:

#include <cstdint> 
//#include <stdint.h> <-- leave that one out, it's not C++ standard! 

std::int_least8_t myIL8 = 5; 

using std::int_least8_t; 
int_least8_t anotherIL8 = 42; 
+0

这并没有解决问题。我添加了两个作为测试,因为增加一个或其他原本并没有解决这个问题,并暂时离开。 – OzBarry

+0

你是不是深究''(也许包括头部)以查看'int_least8_t'是否甚至定义在那里?如果是这样,我们将需要更多的代码 - 包含在'.cpp'中的重要代码可能会重现此问题。 –

+0

它确实在cstdint中定义。我认为主要的问题是boost和C++ cx在一起玩不好。 – OzBarry

相关问题