[02/10] configure: Don't force _WIN32_WINNT to an older version if targeting winphone/winrt

Message ID 1437904678-19444-2-git-send-email-martin@martin.st
State Committed
Commit c6e0829e3696c894d24c8088c3ee30a9c17534c2
Headers show

Commit Message

Martin Storsjö July 26, 2015, 9:57 a.m.
This avoids having to manually set _WIN32_WINNT in --extra-cflags
when targeting these API families, which only was necessary to
work around configure setting _WIN32_WINNT to an older version
by default.
---
 configure | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Jean-Baptiste Kempf July 26, 2015, 10:58 a.m. | #1
On 26 Jul, Martin Storsjö wrote :
> +        # found in the SDK headers by default. (Alternatively, we could force
> +        # _WIN32_WINNT to 0x0602 in that case.)

Why don't you force to 0x0603 in those partition cases?
Wouldn't that be simpler?

With my kindest regards,
Martin Storsjö July 26, 2015, 11:05 a.m. | #2
On Sun, 26 Jul 2015, Jean-Baptiste Kempf wrote:

> On 26 Jul, Martin Storsjö wrote :
>> +        # found in the SDK headers by default. (Alternatively, we could force
>> +        # _WIN32_WINNT to 0x0602 in that case.)
>
> Why don't you force to 0x0603 in those partition cases?
> Wouldn't that be simpler?

We could do that as well, but I tried to minimize the number of cflags we 
add (even internally within the build system), so if code in general works 
without setting _WIN32_WINNT at all (except for the dxva2/d3d11va 
overriding, as tweaked in 1/10) I'd rather go that way. But I don't have a 
strong opinion here.

// Martin
Hendrik Leppkes July 26, 2015, 11:07 a.m. | #3
On Sun, Jul 26, 2015 at 1:05 PM, Martin Storsjö <martin@martin.st> wrote:
> On Sun, 26 Jul 2015, Jean-Baptiste Kempf wrote:
>
>> On 26 Jul, Martin Storsjö wrote :
>>>
>>> +        # found in the SDK headers by default. (Alternatively, we could
>>> force
>>> +        # _WIN32_WINNT to 0x0602 in that case.)
>>
>>
>> Why don't you force to 0x0603 in those partition cases?
>> Wouldn't that be simpler?
>
>
> We could do that as well, but I tried to minimize the number of cflags we
> add (even internally within the build system), so if code in general works
> without setting _WIN32_WINNT at all (except for the dxva2/d3d11va
> overriding, as tweaked in 1/10) I'd rather go that way. But I don't have a
> strong opinion here.

I agree with that, keeping the CFLAG overrides smaller is generally
best, so LGTM.
Steve Lhomme July 26, 2015, 2:51 p.m. | #4
On Sun, Jul 26, 2015 at 12:58 PM, Jean-Baptiste Kempf <jb@videolan.org> wrote:
> On 26 Jul, Martin Storsjö wrote :
>> +        # found in the SDK headers by default. (Alternatively, we could force
>> +        # _WIN32_WINNT to 0x0602 in that case.)
>
> Why don't you force to 0x0603 in those partition cases?
> Wouldn't that be simpler?

In <sdkddkver.h> on the WP8.1 SDK (included at the top of <windows.h>) there is:

#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
#define  _WIN32_WINNT   0x0603
#endif

I think depending on the SDK you use it sets the minimum version
already. So when building for WinRT/WP/W10 that shouldn't be an issue.

There's a chance building with clang we may not have such luck.

> With my kindest regards,
>
> --
> Jean-Baptiste Kempf
> http://www.jbkempf.com/ - +33 672 704 734
> Sent from my Electronic Device
> _______________________________________________
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
Martin Storsjö July 26, 2015, 4:53 p.m. | #5
On Sun, 26 Jul 2015, Steve Lhomme wrote:

> On Sun, Jul 26, 2015 at 12:58 PM, Jean-Baptiste Kempf <jb@videolan.org> wrote:
>> On 26 Jul, Martin Storsjö wrote :
>>> +        # found in the SDK headers by default. (Alternatively, we could force
>>> +        # _WIN32_WINNT to 0x0602 in that case.)
>>
>> Why don't you force to 0x0603 in those partition cases?
>> Wouldn't that be simpler?
>
> In <sdkddkver.h> on the WP8.1 SDK (included at the top of <windows.h>) there is:
>
> #if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
> #define  _WIN32_WINNT   0x0603
> #endif
>
> I think depending on the SDK you use it sets the minimum version
> already. So when building for WinRT/WP/W10 that shouldn't be an issue.

Ok, so I take this as consensus that this patch is ok.

// Martin

Patch

diff --git a/configure b/configure
index b76f838..9ccd0da 100755
--- a/configure
+++ b/configure
@@ -3789,8 +3789,19 @@  probe_libc(){
         # in such new versions and producing binaries requiring windows 7.0.
         # Therefore explicitly set the default to XP unless the user has
         # set something else on the command line.
+        # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
+        # family. For these cases, configure is free to use any functions
+        # found in the SDK headers by default. (Alternatively, we could force
+        # _WIN32_WINNT to 0x0602 in that case.)
         check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
-            add_${pfx}cppflags -D_WIN32_WINNT=0x0502
+            { check_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0502; }
+#ifdef WINAPI_FAMILY
+#include <winapifamily.h>
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#error not desktop
+#endif
+#endif
+EOF
     elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
         eval ${pfx}libc_type=klibc
     elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then