azure-core
1.7.0-beta.1
inc
azure
core
platform.hpp
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// SPDX-License-Identifier: MIT
3
9
// The proper way to check for "UWP/NOT UWP" (*):
10
// 1. Include this file, so that AZ_PLATFORM_WINDOWS becomes available.
11
// 2. Include windows.h (**)
12
// 3. Use "#if !defined(WINAPI_PARTITION_DESKTOP) || WINAPI_PARTITION_DESKTOP" (***) as a condition
13
// meant to detect as fully-featured Win32 API (i.e. registry access, FileOpen() etc.) = "NOT UWP"
14
// (4.) "#else" you are on "UWP" (*)
15
// 5. Some features (i.e. WinHTTP) may have support for some non-traditional-Win32 desktops, yet not
16
// the entirety of "UWP"(*). For example, WinHTTP would currently compile and work on the following:
17
// WINAPI_PARTITION_DESKTOP, WINAPI_PARTITION_SYSTEM, WINAPI_PARTITION_GAMES, so more complex
18
// conditions are possible (****).
19
//
20
// --
21
// (*) - "UWP" is oversimplification, we use it in this comment as an umbrella term to represent all
22
// the Windows platforms (UWP itself, Phone OS, Windows Store, etc) that do not allow some Win32
23
// APIs such as registry access.
24
// (**) - Including windows.h brings up WINAPI_PARTITION_DESKTOP macro (***). The reason we don't
25
// simply include windows.h in this header and declare some sort of a "AZ_PLATFORM_WINDOWS_UWP"
26
// macro in this file is that some places do need to include windows.h when WIN32_LEAN_AND_MEAN is
27
// defined, others do not. So we defer this to each Azure SDK .cpp to do the inclusion as it best
28
// fits. Plus, theoretically, you may want to check for AZ_PLATFORM_WINDOWS, yet you don't need
29
// anything from windows.h header.
30
// (***) - What is happening here: "WINAPI_PARTITION_DESKTOP" may not be defined on some old Windows
31
// SDKs that existed before a concept of "UWP" came out. Those are your traditional "Full Win32 API"
32
// platforms (Windows 7?). But IF "WINAPI_PARTITION_DESKTOP" is defined, then it can be
33
// either 0 or 1 (simply put). For example, if we are being compiled for the "traditional" Windows
34
// 10 desktop, it has a "Full WIn32 API", it has WINAPI_PARTITION_DESKTOP defined, and
35
// WINAPI_PARTITION_DESKTOP evaluates to 1. Otherwise, it is a UWP, which also has
36
// WINAPI_PARTITION_DESKTOP defined, but it evaluates as 0.
37
// (****) - vcpkg could be limiting the default option, because at the moment it only distinguishes
38
// between "UWP" and "Not UWP". So, if we have a default option indicating whether to build WinHTTP,
39
// the best we can do is to enable build by default on (windows&!uwp). We can't remove the "!uwp"
40
// part, because on some partitions compilation will fail. However, there is always an option for
41
// the customer to run "vcpkg install azure-core-cpp[winhttp]" manually, and the build attempt will
42
// be made (even if targeting macOS or Linux).
43
44
#pragma once
45
46
#if defined(_WIN32)
47
#define AZ_PLATFORM_WINDOWS
48
#elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
49
#define AZ_PLATFORM_POSIX
50
#endif
Generated by
1.8.18