在 2019/7/21 19:09, Liu Hao 写道:
> 在 2019/7/20 22:44, Biswapriyo Nath 写道:
>> Fixed #3.
>>
>>
>>
> 
> This might be good as it doesn't alter old things.
> 
> However, I have noticed that in Win10 SDK the other functions changed
> their partition from `WINAPI_PARTITION_DESKTOP` to
> `WINAPI_PARTITION_APP`. Should we update the partition of them as well?
> 
> 

There is indeed a difference:

In Microsoft Win10 SDK [1], `WINAPI_PARTITION_APP` is defined as
`WINAPI_FAMILY` being any of `WINAPI_FAMILY_DESKTOP_APP`,
`WINAPI_FAMILY_PC_APP`, or `WINAPI_FAMILY_PHONE_APP`. So if
`WINAPI_FAMILY_APP` is defined to be `WINAPI_PARTITION_DESKTOP`, the
sole check `WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)` will expose
these APIs, while in mingw-w64 they will be unavailable.

Moreover, in mingw-w64 we have
```
#define WINAPI_FAMILY_PARTITION(v) ((WINAPI_FAMILY & v) == v)
```
so `WINAPI_FAMILY_PARTITION(WINAPI_FAMILY_DESKTOP_APP)` only enables the
block when BOTH (rather than EITHER OF) `WINAPI_PARTITION_DESKTOP` and
`WINAPI_PARTITION_APP` are defined. Plain
`WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP |
WINAPI_PARTITION_APP)` will lead to unexpected results, because it
expands to
```
((WINAPI_FAMILY & WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_APP)
 == WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_APP)
```
, where `==` has the highest precedence and `|` has the lowest
precedence, so it becomes
```
(
  (
    (
      (
        WINAPI_FAMILY & WINAPI_PARTITION_DESKTOP
      )
      | WINAPI_PARTITION_APP
    )
    == WINAPI_PARTITION_DESKTOP
  )
  | WINAPI_PARTITION_APP
)
```


It concludes that `WINAPI_PARTITION_DESKTOP` shall be used in place of
`WINAPI_PARTITION_APP` here unless this `WINAPI_PARTITION` thing matches
MS behavior.


[1] Windows SDK 10.0.17763.0, shared/winapifamily.h, line 149.


-- 
Best regards,
LH_Mouse

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to