我在Qt creator上使用boost lib开发应用程序,我的平台是Windows8 MSVC2013 64.
我每个人都有两个课程,我正在使用提升标题,
现在我需要使用这个类,当我从其他源文件包含这些类头时,我收到错误
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
任何帮助将不胜感激。
由于 哈里斯
答案 0 :(得分:11)
将#define WIN32_LEAN_AND_MEAN
移至g ++命令行参数列表-DWIN32_LEAN_AND_MEAN
。这对我有帮助
还有一件事帮助我重新排序#include
指令,将boost
包含在所有其他指令之前。