views:

190

answers:

2

Hello Everyone!

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 !

A: 

" a header in the other library has undefined types"

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

ravenspoint
+3  A: 

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.

stijn
Agree - sounds like the #includes need rationalising. It doesn't make sense to be using winsock.h and boost.asio (which uses winsock2.h) in the same compilation unit.
jon hanson