Opened 9 years ago

Closed 8 years ago

#9195 closed Bugs (fixed)

WinRT detection failed

Reported by: anonymous Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

I have a normal desktop programm (using VS2012 & Win7x64) but asio think it is a WinRT app (BOOST_ASIO_WINDOWS_RUNTIME is set).

To fix this issue I have to update WinRT detection in boost\asio\detail\config.hpp line 458:

#  if (WINAPI_FAMILY == WINAPI_FAMILY_APP)

instead of

#  if ((WINAPI_FAMILY & WINAPI_PARTITION_APP) != 0)

Change History (4)

comment:1 by chris_kohlhoff, 9 years ago

I suspect the problem is even more complicated, because I also need to ensure the macros in winapifamily.h are defined ahead of the test. As that header is only available from the v8.0 sdk and later, I've enclosed that #include within a test for __cplusplus_winrt.

Can you please try the following and let me know if it works for you:

Index: config.hpp
===================================================================
--- config.hpp  (revision 86090)
+++ config.hpp  (working copy)
@@ -454,11 +454,12 @@
 
 // WinRT target.
 #if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
-# if defined(WINAPI_FAMILY)
-#  if ((WINAPI_FAMILY & WINAPI_PARTITION_APP) != 0)
+# if defined(__cplusplus_winrt)
+#  include <winapifamily.h>
+#  if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
 #   define BOOST_ASIO_WINDOWS_RUNTIME 1
-#  endif // ((WINAPI_FAMILY & WINAPI_PARTITION_APP) != 0)
-# endif // defined(WINAPI_FAMILY)
+#  endif // WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
+# endif // defined(__cplusplus_winrt)
 #endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
 
 // Windows target. Excludes WinRT.
@@ -869,12 +870,12 @@
 #   endif // ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)
 #  endif // defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 # endif // defined(__linux__)
-# if defined(BOOST_ASIO_MSVC) && defined(WINAPI_FAMILY)
+# if defined(BOOST_ASIO_MSVC) && defined(BOOST_ASIO_WINDOWS_RUNTIME)
 #  if (_MSC_VER >= 1700)
 #   define BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION 1
 #   define BOOST_ASIO_THREAD_KEYWORD __declspec(thread)
 #  endif // (_MSC_VER >= 1700)
-# endif // defined(BOOST_ASIO_MSVC) && defined(WINAPI_FAMILY)
+# endif // defined(BOOST_ASIO_MSVC) && defined(BOOST_ASIO_WINDOWS_RUNTIME)
 #endif // !defined(BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
 #if !defined(BOOST_ASIO_THREAD_KEYWORD)
 # define BOOST_ASIO_THREAD_KEYWORD __thread

comment:2 by anonymous, 9 years ago

Your code is working for me. Thanks!

in reply to:  2 comment:3 by ramesh.502@…, 9 years ago

Replying to anonymous:

Your code is working for me. Thanks!

Hi, I want to use the BOOST lib for WINRT.Can you please help me how to get code for WINRT windows 8.

comment:4 by chris_kohlhoff, 8 years ago

Resolution: fixed
Status: newclosed

Was fixed for boost 1.55 in r86152.

Note: See TracTickets for help on using tickets.