I use Windows 11 64 bits and Cygwin 64 bits.
I need to build a project using boost asio without POSIX libraries. The project is built using Eclipse CDT toolset.
I can't use the POSIX libraries here because of the constraints of the project but in another context, I use this project built with Cygwin using POSIX libraries installed from the Cygwin installer and it works well.
The following defined symbols are used in the command line :
__USE_W32_SOCKETS
_WIN32_WINNT=0x0A00
BOOST_WINDOWS
But it result in many errors :
In file included from /usr/include/boost/asio/detail/win_static_mutex.hpp:71,
from /usr/include/boost/asio/detail/static_mutex.hpp:23,
from /usr/include/boost/asio/detail/win_global.hpp:19,
from /usr/include/boost/asio/detail/global.hpp:23,
from /usr/include/boost/asio/impl/system_executor.hpp:19,
from /usr/include/boost/asio/system_executor.hpp:129,
from /usr/include/boost/asio/associated_executor.hpp:21,
from /usr/include/boost/asio.hpp:21,
from ../src/AsioExample.cpp:10:
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp: In member function 'int boost::asio::detail::win_static_mutex::do_init()':
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:48:3: error: '_snwprintf' was not declared in this scope; did you mean 'vsniprintf'?
48 | _snwprintf(
| ^~~~~~~~~~
| vsniprintf
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:3: error: expected 'catch' before '__except'
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ^~~~~~~~
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:3: error: expected '(' before '__except'
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ^~~~~~~~
| (
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:3: error: expected type-specifier before '__except'
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ^~~~~~~~
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:11: error: expected ')' before '(' token
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ~~~~~~~~^
| )
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:11: error: expected '{' before '(' token
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:116:63: error: expected ';' before '{' token
116 | ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
| ^
| ;
117 | {
| ~
I visited this thread : how-to-use-boost-asio-library-with-cygwin-64-bit
But the given solution is not what I want to get here.
As the boost asio documentation indicates that we need to add the flag __USE_W32_SOCKETS
to build it, I suppose it is possible but I can't find the proper solution. Can someone give some hints to achieve this?