c – 错误WinSock.h已被包含在Boost Windows Qt中

前端之家收集整理的这篇文章主要介绍了c – 错误WinSock.h已被包含在Boost Windows Qt中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Qt creator上使用boost lib开发应用程序,我的平台是 Windows8 MSVC2013 64.

每个我有两个类我使用boost标头,

现在我需要使用这个类,当我从另一个源文件包含这些类头时,我收到错误

error WinSock.h has already been included

在我的拳头班,我添加升级头像

#define WIN32_LEAN_AND_MEAN
#include <boost/asio.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/read_until.hpp>
#include <boost/bind.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/placeholders.hpp>
#include <boost/foreach.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/thread_time.hpp>
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
#include <boost/bind.hpp>

#include <boost/cstdint.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>

在第二节课中,我以同样的方式使用了标题

#define WIN32_LEAN_AND_MEAN
#include <iostream>

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/thread_time.hpp>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/read_until.hpp>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/read.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <boost/asio/placeholders.hpp>
#include <fstream>
#include <boost/cstdint.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>

我已经在Boost::asio winsock and winsock 2 compatibility issue找到了答案,但我仍然遇到了问题.

编辑:
我的第二个内部使用第一个类头,这是多次包括升级头的原因吗?

我已经将boost头包括在内了

#ifndef class_obj__1
#define class_obj__1
//boost headers
//boost headers  
#endif

任何帮助将不胜感激.

谢谢
哈里斯

解决方法

将#define WIN32_LEAN_AND_MEAN移动到g命令行参数列表为-DWIN32_LEAN_AND_MEAN.这对我有帮助. 还有一件事帮助我重新排序#include指令,将boost包括在所有其他指令之前.
原文链接:/c/111075.html

猜你在找的C&C++相关文章