When does #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) in dxvahd.h Microsoft header file become true
Asked Answered
K

2

7

Hi I am having 2 VC++ solutions "A" & "B" (VS2008) both are having the same codebase (with just few lines of code different). Using DXVAHD.h in both.

dxvahd.h is a standard Microsoft header file. If we open this header file, we see there is a conditional if "#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"

I see that in VC++ solution "A", the above conditional #if statement is false, hence the whole dxvahd header file gets greyed out & is not even compiled!!

Whereas in another solution "B", this conditional #if is true,hence no issues & its working fine.

Can anyone kindly let me know how do I resolve this issue in solution "A", wherein the above #if is getting greyed out / not compiling. PLz help me.

Thanks in advance.

Karlie answered 8/3, 2013 at 10:47 Comment(0)
I
8

Looking at winapifamily.h, you can see that these macros are used to determine what platform you have and what API's are suitable for your platform.

/*
 *  Windows APIs can be placed in a partition represented by one of the below bits.   The 
 *  WINAPI_FAMILY value determines which partitions are available to the client code.
 */

#define WINAPI_PARTITION_DESKTOP   0x00000001
#define WINAPI_PARTITION_APP       0x00000002    

/*
 * A family may be defined as the union of multiple families. WINAPI_FAMILY should be set
 * to one of these values.
 */
#define WINAPI_FAMILY_APP          WINAPI_PARTITION_APP
#define WINAPI_FAMILY_DESKTOP_APP  (WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_APP)    

/*
 * A constant that specifies which code is available to the program's target runtime platform.
 * By default we use the 'desktop app' family which places no restrictions on the API surface. 
 * To restrict the API surface to just the App API surface, define WINAPI_FAMILY to WINAPI_FAMILY_APP.
 */
#ifndef WINAPI_FAMILY
#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
#endif

/* Macro to determine if a partition is enabled */
#define WINAPI_FAMILY_PARTITION(Partition)  ((WINAPI_FAMILY & Partition) == Partition)

/* Macro to determine if only one partition is enabled from a set */
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)

So your WINAPI_PARTITION_DESKTOP would only be set if you are running on a Desktop family of the the system.

Instructor answered 8/3, 2013 at 11:2 Comment(4)
But both the solutions "A" & "B" are compiled & run on the same system,same OS,same platform. I'm really wondering if it can be any settings in VS2008, which is causing the difference in 2 solutions.Karlie
@Karlie AFAIK this is for Metro apps vs Desktop apps, last time I checked, Metro wasn't supported in VS2008. Am I wrong?Instructor
Running both the solutions on desktop Win7 & they are both desktop apps.Karlie
@Karlie if the API's are not supported or part of VS2008, then it won't work. If there's no header anywhere in the library that defines any of these things, then it will show up as not defined. For Metro support, you need to be in VS2010 minimal, I suspect. It may even require 2012Instructor
C
0

WINAPI_FAMILY is also set depending on the targeted Windows version.

See this discussion and the linked blog post series.

In particular, if you're not writing an "App" (for >= Win 8) then:

Prefer use of the standard _WIN32_WINNT Windows Defines for selecting the correct Win32 API (i.e. many Win32 APIs required for use in Windows Store apps are the Vista (0x0600), Windows 7 (0x0601), or Windows 8 (0x0602) version.

You can use WINVER or _WIN32_WINNT.

Communication answered 30/4, 2016 at 9:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.