使用winsock.h 的库出现问题

发布于 2024-08-11 00:29:37 字数 336 浏览 4 评论 0原文

我有一个使用 Boost.Asio 和 Intel IPP-Library 附带的 Media-Decoding-Samples 的项目。问题如下。如果我在没有定义 WIN32_LEAN_AND_MEAN 的情况下编译项目,Asio 会抱怨臭名昭著的“winsock.h 已包含”错误。如果我定义宏,则其他库中的标头具有未定义的类型,因为它依赖于 windows.h 包括 winsock.h。我尝试手动将winsock.h添加到该标头中,但这使Boost.Asio再次大喊大叫。我能想到的唯一解决方案是检查每个编译单元并确保 Asio 始终首先包含在内。由于项目的规模和复杂性(以及该解决方案的丑陋),我想找到一种更好的方法。

提前致谢 !

I have a project that uses Boost.Asio and the Media-Decoding-Samples that come with the Intel IPP-Library. The problem is the following. If I compile the project without defining WIN32_LEAN_AND_MEAN, Asio complains with the infamous "winsock.h already included" error. If I define the macro, a header in the other library has undefined types, because it relies on windows.h including winsock.h. I tried adding winsock.h to that header manually, but this makes Boost.Asio cry out again. The only solution I can think of would be to go through every compilation unit and make sure that Asio is always included first. Due to the size and complexity of the project (and the uglyness of that solution) I would like to find a better way.

Thanks in advance !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼趣 2024-08-18 00:29:38

如果您拆分源代码并确保不在包含 Asio 和 IPP 的应用程序中使用某种通用标头,则可以解决此问题。因此,需要 Asio 的源文件包含 Boost 标头,需要 IPP 的源文件包含 IPP 标头,但需要引用两者的类的标头文件不应包含任何外部标头,并在需要时使用前向声明。

you can get around this if you split up your source and make sure not to use some kind of common header in your application in which you incude both Asio and IPP. So the source files needing Asio include Boost headers, the source files needing IPP include the IPP headers, but the header files for your classes that need to refer to both should not include any external headers, and use forward declarations if needed.

叶落知秋 2024-08-18 00:29:38

“其他库中的标头具有未定义的类型”有

多少?有多复杂?也许你可以定义这些类型?

" a header in the other library has undefined types"

How many? How complicated? Perhaps you could define those types?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文