### Boost.Build: Conditional Build with OR Logic Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This example demonstrates using the `or` logical operator within `predef-require` to build a library (`my_special_lib`) if the operating system is either Windows or VMS. It checks for the presence of `BOOST_OS_WINDOWS` or `BOOST_OS_VMS`. ```boost.build import path-to-predef-src/tools/check/predef : check require : predef-check predef-require ; lib my_special_lib : source.cpp : [ predef-require "BOOST_OS_WINDOWS" or "BOOST_OS_VMS"] ; ``` -------------------------------- ### Boost.Build: Conditional Feature Definition Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This example uses the `predef-check` rule to conditionally define a preprocessor macro (`ENABLE_WMF`) for an executable (`my_special_exe`). It defines `ENABLE_WMF=0` if `BOOST_OS_WINDOWS == 0`, and `ENABLE_WMF=1` otherwise. ```boost.build import path-to-predef-src/tools/check/predef : check require : predef-check predef-require ; exe my_special_exe : source.cpp : [ predef-check "BOOST_OS_WINDOWS == 0" : : ENABLE_WMF=0 : ENABLE_WMF=1 ] ; ``` -------------------------------- ### Utility Macros for Version Decomposition (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index Demonstrates the use of Boost Preprocessor's utility macros to decompose common compiler version macros. The example shows how to decompose a 3-digit version macro for the EDG compiler. ```cpp #include #define BOOST_COMP_EDG BOOST_PREDEF_MAKE_N_N_N(__EDG_VERSION__) ``` -------------------------------- ### Boost.Build: Conditional Build for Windows Program Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This example demonstrates how to use `predef-require` in Boost.Build to conditionally build an executable (`my_windows_program`) only when the target operating system is Windows. It utilizes the `predef-check` tool from Boost.Predef. ```boost.build import path-to-predef-src/tools/check/predef : check require : predef-check predef-require ; exe my_windows_program : windows_source.cpp : [ predef-require "BOOST_OS_WINDOWS" ] ; ``` -------------------------------- ### Check SIMD Extension Range (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This example demonstrates checking for a range of SIMD extensions on x86, such as SSE2 through SSSE3. It uses logical AND (`&&`) to combine version checks with greater than or equal to and less than or equal to operators, relying on ``. ```c++ #include #include int main() { #if BOOST_HW_SIMD_X86 >= BOOST_HW_SIMD_X86_SSE2_VERSION &&\ BOOST_HW_SIMD_X86 <= BOOST_HW_SIMD_X86_SSSE3_VERSION std::cout << "This is SSE2, SSE3 and SSSE3!" << std::endl; #endif return 0; } ``` -------------------------------- ### Check GCC Compiler Version Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index Example demonstrating how to check if the GCC compiler version is at least 4.0.0 using predef macros and `BOOST_VERSION_NUMBER`. ```c++ #include #include int main() { if (BOOST_COMP_GNUC >= BOOST_VERSION_NUMBER(4,0,0)) std::cout << "GCC compiler is at least version 4.0.0" << std::endl; else std::cout << "GCC compiler is at older than version 4.0.0, or not a GCC compiler" << std::endl; return 0; } ``` -------------------------------- ### Check SIMD Extension Range (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/index Enables checking for a range of SIMD extensions on the x86 architecture, leveraging the inclusive nature of SIMD versioning. This example checks if SSE2, SSE3, and SSSE3 are all enabled. It requires 'boost/predef/hardware/simd.h'. ```cpp #include #include int main() { #if BOOST_HW_SIMD_X86 >= BOOST_HW_SIMD_X86_SSE2_VERSION && \ BOOST_HW_SIMD_X86 <= BOOST_HW_SIMD_X86_SSSE3_VERSION std::cout << "This is SSE2, SSE3 and SSSE3!" << std::endl; #endif return 0; } ``` -------------------------------- ### Check Specific SIMD Extension Version (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This example shows how to check for a specific SIMD extension, like SSE3 on x86, by comparing the architecture-specific macro (e.g., `BOOST_HW_SIMD_X86`) against its version define (e.g., `BOOST_HW_SIMD_X86_SSE3_VERSION`). This requires the `` header. ```c++ #include #include int main() { #if BOOST_HW_SIMD_X86 >= BOOST_HW_SIMD_X86_SSE3_VERSION std::cout << "This is SSE3!" << std::endl; #endif return 0; } ``` -------------------------------- ### Boost Predef Header Structure: Copyright, Include Guard, and Basic Includes Source: https://www.boost.org/doc/libs/latest/libs/predef/index This snippet demonstrates the initial section of a Boost Predef header file. It includes the copyright and license statement, followed by the necessary include guard to prevent multiple inclusions. It also shows how to include dependency headers and versioning utility headers if required. ```c++ /* Copyright Jane Doe YYYY Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_PREDEF_category_tag_H #define BOOST_PREDEF_category_tag_H #include #include #include ``` -------------------------------- ### Detect GNU GCC Compiler Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index Example showing how to directly detect if the GNU GCC compiler is being used. Predef macros are defined as 0 when not detected. ```c++ #include #include int main() { if (BOOST_COMP_GNUC) std::cout << "This is GNU GCC!" << std::endl; else std::cout << "Not GNU GCC." << std::endl; return 0; } ``` -------------------------------- ### Standard Boost Predef Header Structure Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This code block demonstrates the essential components of a typical Boost Predef header file. It includes the copyright notice, include guard, necessary dependency includes, Asciidoctor documentation tags, the zero-value default definition, and the main detection logic for a predef macro. This structure ensures consistency and facilitates IDE integration. ```c++ /* Copyright Jane Doe YYYY Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_PREDEF_category_tag_H #define BOOST_PREDEF_category_tag_H #include #include #include /* tag::reference[] = `BOOST_category_tag` Documentation about what is detected. */ #define BOOST_category_tag BOOST_VERSION_NUMBER_NOT_AVAILABLE #if (condition_a) # undef BOOST_category_tag # if (condition_b) # define BOOST_category_tag BOOST_VERSION_NUMBER(major,minor,patch) # else # define BOOST_category_tag BOOST_VERSION_NUMBER_AVAILABLE # endif #endif #if BOOST_category_tag # define BOOST_category_tag_AVAILABLE #endif #define BOOST_category_tag_NAME "Name" #endif #include BOOST_PREDEF_DECLARE_TEST(BOOST_category_tag,BOOST_category_tag_NAME) ``` -------------------------------- ### Check General SIMD Availability (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This snippet demonstrates how to check if any SIMD extension is available on the system using the `BOOST_HW_SIMD_AVAILABLE` macro. It requires including the `` header. ```c++ #include #include int main() { #if defined(BOOST_HW_SIMD_AVAILABLE) std::cout << "SIMD detected!" << std::endl; #endif return 0; } ``` -------------------------------- ### Check UWP Platform Availability (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/index Determines if the current development environment supports targeting Universal Windows Platform (UWP). This macro is defined when the necessary SDKs and build configurations are in place. It is defined in the 'boost/predef/platform/windows_uwp.h' header. ```cpp #include #include int main() { #if defined(BOOST_PLAT_WINDOWS_UWP) std::cout << "Universal Windows Platform is available." << std::endl; #else std::cout << "Universal Windows Platform is not available." << std::endl; #endif return 0; } ``` -------------------------------- ### Boost Predef Header Structure: Availability and Name Macros Source: https://www.boost.org/doc/libs/latest/libs/predef/index This section shows how to define the `*_AVAILABLE` macro, which is set if the main predef macro is defined (i.e., detected). It also demonstrates defining a `*_NAME` macro to provide a human-readable string representation of the detected predef. ```c++ #if BOOST_category_tag # define BOOST_category_tag_AVAILABLE #endif #define BOOST_category_tag_NAME "Name" ``` -------------------------------- ### BOOST_ARCH_BLACKFIN Detection Macros (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index Lists the preprocessor symbols used to detect Blackfin Processors from Analog Devices. These symbols primarily indicate the presence of the architecture rather than specific versions. ```cpp // Blackfin Processors from Analog Devices. // Symbol | Version // __bfin__ | **detection** // __BFIN__ | **detection** // bfin | **detection** // BFIN | **detection** ``` -------------------------------- ### Blackfin Architecture Detection - C/C++ Source: https://www.boost.org/doc/libs/latest/libs/predef/index This C/C++ preprocessor code snippet provides macros for detecting the Blackfin processor architecture. It uses common symbols like `__bfin__`, `__BFIN__`, `bfin`, and `BFIN` for detection. ```c++ #define BOOST_ARCH_BLACKFIN \ BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__bfin__) # define BOOST_ARCH_BLACKFIN BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__BFIN__) # define BOOST_ARCH_BLACKFIN BOOST_VERSION_NUMBER_AVAILABLE #elif defined(bfin) # define BOOST_ARCH_BLACKFIN BOOST_VERSION_NUMBER_AVAILABLE #elif defined(BFIN) # define BOOST_ARCH_BLACKFIN BOOST_VERSION_NUMBER_AVAILABLE ``` -------------------------------- ### Guidelines for Including Headers in Predef Detections Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index When adding new predefs, guidelines should be followed regarding header inclusions to minimize potential conflicts and dependencies. Detection logic should ideally avoid including extra headers that are not part of the default build. If header inclusion is necessary, it should be guarded within the detection logic where possible. If unconditional includes are required, prefer headers with the least impact on definitions and dependencies. ```text * The detection should avoid including extra headers that might otherwise not be included by default. * If the detection must include a header, prefer guarding it within the detection if possible. * If the detection must include headers unconditionally, and has a choice of headers to include, prefer the ones with the least impact. I.e. include the one with the minimal set of definitions and other dependencies. ``` -------------------------------- ### BOOST_ARCH_E2K Detection Macros (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This snippet shows the preprocessor symbols used for the E2K architecture. It includes a general detection symbol and a specific version symbol. ```cpp // E2K architecture. // Symbol | Version // __e2k__ | **detection** // __e2k__ | V.0.0 ``` -------------------------------- ### Requirements for New Boost Predefs Header Source: https://www.boost.org/doc/libs/latest/libs/predef/index Guidelines for creating new predef headers in Boost. Key requirements include using the Boost Software License, defaulting to BOOST_VERSION_NUMBER_NOT_AVAILABLE, and redefining to a non-zero value upon detection. It also specifies defining *_AVAILABLE and symbolic constant string name macros. ```cpp The predef must, by default, be defined as `BOOST_VERSION_NUMBER_NOT_AVAILABLE`. If possible, the predef will be defined as the version number detected. The predef must define `*_AVAILABLE` macros as needed. The predef must define a symbolic constant string name macro. ``` -------------------------------- ### Boost.Build: Conditional Build for Library (Not Windows or VMS) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This snippet shows how to use `predef-require` with multiple relational comparisons to build a library (`my_special_lib`) only if the operating system is neither Windows nor VMS. It checks if `BOOST_OS_WINDOWS` and `BOOST_OS_VMS` are not equal to 0. ```boost.build import path-to-predef-src/tools/check/predef : check require : predef-check predef-require ; lib my_special_lib : source.cpp : [ predef-require "BOOST_OS_WINDOWS != 0" "BOOST_OS_VMS != 0"] ; ``` -------------------------------- ### Detect UWP Windows Server Platform Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definition for detecting UWP Windows Server development platform. Checks WINAPI_FAMILY macro for WINAPI_FAMILY_SERVER. ```c++ #ifdef BOOST_PLAT_WINDOWS_SERVER // UWP Windows Server detected via: // WINAPI_FAMILY == WINAPI_FAMILY_SERVER #endif ``` -------------------------------- ### Detect UWP Windows Store Platform Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definition for detecting UWP Windows Store development platform. Checks WINAPI_FAMILY macro for WINAPI_FAMILY_PC_APP or deprecated WINAPI_FAMILY_APP. ```c++ #ifdef BOOST_PLAT_WINDOWS_STORE // UWP Windows Store detected via: // WINAPI_FAMILY == WINAPI_FAMILY_PC_APP // or WINAPI_FAMILY == WINAPI_FAMILY_APP (deprecated) #endif ``` -------------------------------- ### Detect UWP Windows Desktop Platform Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definition for detecting UWP Windows Desktop development platform. Checks WINAPI_FAMILY macro for WINAPI_FAMILY_DESKTOP_APP or absence of BOOST_PLAT_WINDOWS_UWP. ```c++ #ifdef BOOST_PLAT_WINDOWS_DESKTOP // UWP Windows Desktop detected via: // WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP // or !BOOST_PLAT_WINDOWS_UWP #endif ``` -------------------------------- ### Detect UWP Windows System Platform Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definition for detecting UWP Windows System development platform. Checks WINAPI_FAMILY macro for WINAPI_FAMILY_SYSTEM. ```c++ #ifdef BOOST_PLAT_WINDOWS_SYSTEM // UWP Windows System detected via: // WINAPI_FAMILY == WINAPI_FAMILY_SYSTEM #endif ``` -------------------------------- ### Include Boost Predef Header Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index To use all automatically defined predefs, include the single top-level header file for the Boost Predef library. ```c++ #include ``` -------------------------------- ### Detect CloudABI Platform with BOOST_PLAT_CLOUDABI Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definition for detecting CloudABI platform. Uses __CloudABI__ compiler-defined symbol for detection. ```c++ #ifdef BOOST_PLAT_CLOUDABI // CloudABI platform detected via __CloudABI__ #endif ``` -------------------------------- ### Emulated Predef Detection in Boost Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This code demonstrates the approach for detecting emulated predefs, specifically for compilers. It introduces a local `*_DETECTION` macro to manage the detection process and conditionally defines either the base predef (`BOOST_COMP_compiler`) or the emulated version (`BOOST_COMP_compiler_EMULATED`). This allows for accurate identification of both the original and emulated compiler. ```c++ #if (condition_a) # if (condition_b) ``` -------------------------------- ### Detect MinGW Platform Variants with Version Information Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definitions for detecting MinGW platforms (generic, 32-bit, and 64-bit variants). Provides version information as major and minor version numbers available for all variants. ```c++ #ifdef BOOST_PLAT_MINGW // Generic MinGW detected via __MINGW32__ or __MINGW64__ // Version available from __MINGW64_VERSION_MAJOR, __MINGW64_VERSION_MINOR // or __MINGW32_VERSION_MAJOR, __MINGW32_VERSION_MINOR (V.R.0 format) #endif #ifdef BOOST_PLAT_MINGW32 // MinGW 32-bit detected via __MINGW32__ // Version: __MINGW32_VERSION_MAJOR, __MINGW32_VERSION_MINOR (V.R.0) #endif #ifdef BOOST_PLAT_MINGW64 // MinGW-w64 detected via __MINGW64__ // Version: __MINGW64_VERSION_MAJOR, __MINGW64_VERSION_MINOR (V.R.0) #endif ``` -------------------------------- ### BOOST_ARCH_WORD_BITS Macros Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index Macros to detect the native word size (in bits) of the current architecture. Includes a primary macro for the word size and specific macros for 16, 32, and 64-bit detection. ```APIDOC ## BOOST_ARCH_WORD_BITS Macros ### Description Detects the native word size, in bits, for the current architecture. There are two types of macros for this detection: * `BOOST_ARCH_WORD_BITS`: Gives the number of word size bits (16, 32, 64). * `BOOST_ARCH_WORD_BITS_16`, `BOOST_ARCH_WORD_BITS_32`, and `BOOST_ARCH_WORD_BITS_64`: Indicate when the given word size is detected. These macros allow for both single checks and direct use of the size in code. ### Notes The word size is determined manually on each architecture. Hence, use of the `wordsize.h` header will also include all the architecture headers. ``` -------------------------------- ### Boost Predef Header Structure: Documentation Tag and Zero-Value Definition Source: https://www.boost.org/doc/libs/latest/libs/predef/index This code segment illustrates how to embed Asciidoctor documentation within a predef header file, enabling features like in-line help in IDEs. It's followed by the zero-value default definition of the predef macro, which is recommended for providing a baseline state. ```c++ /* tag::reference[] = `BOOST_category_tag` Documentation about what is detected. */ #define BOOST_category_tag BOOST_VERSION_NUMBER_NOT_AVAILABLE ``` -------------------------------- ### Detect iOS Simulator Platform with BOOST_PLAT_IOS_SIMULATOR Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definition for detecting iOS simulator platform. Uses TARGET_IPHONE_SIMULATOR and TARGET_OS_SIMULATOR symbols for detection. ```c++ #ifdef BOOST_PLAT_IOS_SIMULATOR // iOS simulator detected via: // TARGET_IPHONE_SIMULATOR - detection // TARGET_OS_SIMULATOR - detection #endif ``` -------------------------------- ### Boost.Build: `check` Rule Definition Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This shows the signature for the `check` rule in Boost.Build, which offers more granular control over conditional logic. It accepts expressions, an optional language, properties to add when true, and properties to add when false. ```boost.build rule check ( expressions + : language ? : true-properties * : false-properties * ) ``` -------------------------------- ### BOOST_ARCH_M68K Detection Macros (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This snippet outlines the preprocessor symbols for the Motorola 68k architecture. It covers general detection and specific versions like 68000, 68010, 68020, 68030, 68040, and 68060, mapping them to their respective versions. ```cpp // Motorola 68k architecture. // Symbol | Version // __m68k__ | **detection** // M68000 | **detection** // __mc68060__ | 6.0.0 // mc68060 | 6.0.0 // __mc68060 | 6.0.0 // __mc68040__ | 4.0.0 // mc68040 | 4.0.0 // __mc68040 | 4.0.0 // __mc68030__ | 3.0.0 // mc68030 | 3.0.0 // __mc68030 | 3.0.0 // __mc68020__ | 2.0.0 // mc68020 | 2.0.0 // __mc68020 | 2.0.0 // __mc68010__ | 1.0.0 // mc68010 | 1.0.0 // __mc68010 | 1.0.0 // __mc68000__ | 0.0.1 // mc68000 | 0.0.1 // __mc68000 | 0.0.1 ``` -------------------------------- ### Convex Architecture Detection - C/C++ Source: https://www.boost.org/doc/libs/latest/libs/predef/index This C/C++ preprocessor code snippet defines macros for detecting Convex Computer architectures. It includes specific versions like `__convex_c1__`, `__convex_c2__`, `__convex_c32__`, `__convex_c34__`, and `__convex_c38__`. ```c++ #define BOOST_ARCH_CONVEX \ BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__convex_c38__) # define BOOST_ARCH_CONVEX BOOST_VERSION_NUMBER(3,8,0) #elif defined(__convex_c34__) # define BOOST_ARCH_CONVEX BOOST_VERSION_NUMBER(3,4,0) #elif defined(__convex_c32__) # define BOOST_ARCH_CONVEX BOOST_VERSION_NUMBER(3,2,0) #elif defined(__convex_c2__) # define BOOST_ARCH_CONVEX BOOST_VERSION_NUMBER(2,0,0) #elif defined(__convex_c1__) # define BOOST_ARCH_CONVEX BOOST_VERSION_NUMBER(1,0,0) #elif defined(__convex__) # define BOOST_ARCH_CONVEX BOOST_VERSION_NUMBER_AVAILABLE ``` -------------------------------- ### BOOST_ARCH_ARM Detection Macros (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This snippet details the various preprocessor symbols used for detecting ARM architectures, including different versions and specific types like Thumb and ARM64. It maps symbols to version numbers where available. ```cpp // ARM architecture. // Symbol | Version // __ARM_ARCH | V.0.0 // __TARGET_ARCH_ARM | V.0.0 // __TARGET_ARCH_THUMB | V.0.0 // _M_ARM | V.0.0 // __arm64 | 8.0.0 // _M_ARM64 | 8.0.0 // __aarch64__ | 8.0.0 // __AARCH64EL__ | 8.0.0 // __ARM_ARCH_7__ | 7.0.0 // __ARM_ARCH_7A__ | 7.0.0 // __ARM_ARCH_7R__ | 7.0.0 // __ARM_ARCH_7M__ | 7.0.0 // __ARM_ARCH_6K__ | 6.0.0 // __ARM_ARCH_6Z__ | 6.0.0 // __ARM_ARCH_6KZ__ | 6.0.0 // __ARM_ARCH_6T2__ | 6.0.0 // __ARM_ARCH_5TE__ | 5.0.0 // __ARM_ARCH_5TEJ__ | 5.0.0 // __ARM_ARCH_4T__ | 4.0.0 // __ARM_ARCH_4__ | 4.0.0 ``` -------------------------------- ### E2K Architecture Detection - C/C++ Source: https://www.boost.org/doc/libs/latest/libs/predef/index This C/C++ preprocessor code snippet defines macros for detecting the E2K architecture. It uses the `__e2k__` symbol for detection and versioning. ```c++ #define BOOST_ARCH_E2K \ BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__e2k__) # define BOOST_ARCH_E2K BOOST_VERSION_NUMBER(V,0,0) ``` -------------------------------- ### Boost.Build: Define `require` Rule Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This Boost.Build rule defines a simplified `require` function, which is a special case of the `check` rule. It allows for easier conditional requirement setting based on expressions. ```boost.build rule require ( expressions + : language ? ) { return [ check $(expressions) : $(language) : : no ] ; } ``` -------------------------------- ### Detect VMS Operating System with BOOST_OS_VMS Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definitions for detecting VMS operating system. Uses compiler-defined symbols VMS, __VMS for detection and __VMS_VER for version information in V.R.P format. ```c++ #ifdef BOOST_OS_VMS // VMS detected // Available symbols: // VMS - detection // __VMS - detection // __VMS_VER - version V.R.P #endif ``` -------------------------------- ### Requirements for New Predef Headers in Boost Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index New predef headers in the Boost library must adhere to several requirements to ensure consistency and proper functionality. These include adhering to the Boost Software License, defining predefs to specific initial states (like BOOST_VERSION_NUMBER_NOT_AVAILABLE), and ensuring they are redefined to a non-zero value upon detection. Additionally, predefs should define *_AVAILABLE and symbolic constant string name macros, declare themselves for the testing system, and guarantee uniqueness within their detection category. ```text * The headers must use the Boost Software License. * The predef must, by default, be defined as `BOOST_VERSION_NUMBER_NOT_AVAILABLE`. * The predef must be redefined to a non-zero value once detected. * The predef must, by default, be defined to `BOOST_VERSION_NUMBER_AVAILABLE` when the predef is detected. * If possible, the predef will be defined as the version number detected. * The predef must define `*_AVAILABLE` macros as needed. * The predef must define a symbolic constant string name macro. * The predef must declare itself, after being defined, for the testing system. * The predef must guarantee that it is the only one defined as detected per category. * But a predef can define `*_EMULATED` macros to indicate that it was previously detected by another header and is being "emulated" by the system. Note that the `*_AVAILABLE` macros must still be defined in this situation. ``` -------------------------------- ### IA64 Architecture Detection - C/C++ Source: https://www.boost.org/doc/libs/latest/libs/predef/index This C/C++ preprocessor code snippet defines macros for detecting the Intel Itanium 64 (IA64) architecture. It includes common symbols like `__ia64__`, `_IA64`, `__IA64__`, `__ia64`, `_M_IA64`, and `__itanium__`. ```c++ #define BOOST_ARCH_IA64 \ BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__ia64__) # define BOOST_ARCH_IA64 BOOST_VERSION_NUMBER_AVAILABLE #elif defined(_IA64) # define BOOST_ARCH_IA64 BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__IA64__) # define BOOST_ARCH_IA64 BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__ia64) # define BOOST_ARCH_IA64 BOOST_VERSION_NUMBER_AVAILABLE #elif defined(_M_IA64) # define BOOST_ARCH_IA64 BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__itanium__) # define BOOST_ARCH_IA64 BOOST_VERSION_NUMBER_AVAILABLE ``` -------------------------------- ### BOOST_ARCH_IA64 Detection Macros (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index Lists the preprocessor symbols for detecting the Intel Itanium 64 architecture. These symbols indicate the presence of the architecture and are generally used for detection purposes. ```cpp // Intel Itanium 64 architecture. // Symbol | Version // __ia64__ | **detection** // _IA64 | **detection** // __IA64__ | **detection** // __ia64 | **detection** // _M_IA64 | **detection** // __itanium__ | **detection** ``` -------------------------------- ### BOOST_ARCH_ALPHA Detection Macros (C++) Source: https://www.boost.org/doc/libs/latest/libs/predef/doc/index This snippet lists the preprocessor symbols used to detect the DEC Alpha architecture and their associated version numbers. Some symbols only indicate detection, while others map to specific versions. ```cpp // DEC Alpha architecture. // Symbol | Version // __alpha__ | **detection** // __alpha | **detection** // _M_ALPHA | **detection** // __alpha_ev4__ | 4.0.0 // __alpha_ev5__ | 5.0.0 // __alpha_ev6__ | 6.0.0 ``` -------------------------------- ### Detect UWP Windows Phone Platform Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definition for detecting UWP Windows Phone development platform. Checks WINAPI_FAMILY macro for WINAPI_FAMILY_PHONE_APP. ```c++ #ifdef BOOST_PLAT_WINDOWS_PHONE // UWP Windows Phone detected via: // WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP #endif ``` -------------------------------- ### BOOST_PREDEF_MAKE_10 Decimal Version Macros Source: https://www.boost.org/doc/libs/latest/libs/predef/index Set of macros for decomposing vendor version numbers in decimal format. These macros extract version (V), revision (R), and patch (P) components from decimal values, with special handling for year-month patch levels. ```c BOOST_PREDEF_MAKE_10_VPPP(V) BOOST_PREDEF_MAKE_10_VVPPP(V) BOOST_PREDEF_MAKE_10_VR0(V) BOOST_PREDEF_MAKE_10_VRP(V) BOOST_PREDEF_MAKE_10_VRP000(V) BOOST_PREDEF_MAKE_10_VRPPPP(V) BOOST_PREDEF_MAKE_10_VRPP(V) BOOST_PREDEF_MAKE_10_VRR(V) BOOST_PREDEF_MAKE_10_VRRPP(V) BOOST_PREDEF_MAKE_10_VRR000(V) BOOST_PREDEF_MAKE_10_VV00(V) BOOST_PREDEF_MAKE_10_VVR_0PPPPP(V, P) BOOST_PREDEF_MAKE_10_VVRR(V) BOOST_PREDEF_MAKE_10_VVRRP(V) BOOST_PREDEF_MAKE_10_VVRRPP(V) BOOST_PREDEF_MAKE_10_VVRRPPP(V) BOOST_PREDEF_MAKE_10_VVRR0PP00(V) BOOST_PREDEF_MAKE_10_VVRR0PPPP(V) BOOST_PREDEF_MAKE_10_VVRR00PP00(V) ``` -------------------------------- ### Detect Windows Operating System with BOOST_OS_WINDOWS Source: https://www.boost.org/doc/libs/latest/libs/predef/index Preprocessor macro definitions for detecting Microsoft Windows operating system. Checks multiple compiler-defined symbols including _WIN32, _WIN64, __WIN32__, __TOS_WIN__, and __WINDOWS__ for detection. ```c++ #ifdef BOOST_OS_WINDOWS // Windows detected // Available detection symbols: // _WIN32 - detection // _WIN64 - detection // __WIN32__ - detection // __TOS_WIN__ - detection // __WINDOWS__ - detection #endif ``` -------------------------------- ### M68K Architecture Detection - C/C++ Source: https://www.boost.org/doc/libs/latest/libs/predef/index This C/C++ preprocessor code snippet defines macros for detecting Motorola 68k architectures. It covers various models like 68000, 68010, 68020, 68030, 68040, and 68060 with their respective version numbers. ```c++ #define BOOST_ARCH_M68K \ BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__mc68060__) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(6,0,0) #elif defined(mc68060) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(6,0,0) #elif defined(__mc68060) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(6,0,0) #elif defined(__mc68040__) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(4,0,0) #elif defined(mc68040) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(4,0,0) #elif defined(__mc68040) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(4,0,0) #elif defined(__mc68030__) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(3,0,0) #elif defined(mc68030) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(3,0,0) #elif defined(__mc68030) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(3,0,0) #elif defined(__mc68020__) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(2,0,0) #elif defined(mc68020) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(2,0,0) #elif defined(__mc68020) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(2,0,0) #elif defined(__mc68010__) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(1,0,0) #elif defined(mc68010) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(1,0,0) #elif defined(__mc68010) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(1,0,0) #elif defined(__mc68000__) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(0,0,1) #elif defined(mc68000) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(0,0,1) #elif defined(__mc68000) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER(0,0,1) #elif defined(__m68k__) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER_AVAILABLE #elif defined(M68000) # define BOOST_ARCH_M68K BOOST_VERSION_NUMBER_AVAILABLE ``` -------------------------------- ### Boost Predef Header Structure: Detection and Definition Logic Source: https://www.boost.org/doc/libs/latest/libs/predef/index This snippet outlines the core logic for detecting and defining a predef macro. It includes an overall check, undefines the default macro, and then conditionally defines the macro with either a specific version number or a general 'available' status. It ensures a fallback definition is always present if the predef is detected. ```c++ #if (condition_a) # undef BOOST_category_tag # if (condition_b) # define BOOST_category_tag BOOST_VERSION_NUMBER(major,minor,patch) # else # define BOOST_category_tag BOOST_VERSION_NUMBER_AVAILABLE # endif #endif ``` -------------------------------- ### ARM Architecture Detection - C/C++ Source: https://www.boost.org/doc/libs/latest/libs/predef/index This C/C++ preprocessor code snippet defines macros for detecting various ARM architectures, including ARMv7, ARMv8 (aarch64), and older versions. It covers common preprocessor symbols used for ARM detection. ```c++ #define BOOST_ARCH_ARM \ BOOST_VERSION_NUMBER_AVAILABLE #elif defined(__aarch64__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(8,0,0) #elif defined(__arm64) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(8,0,0) #elif defined(_M_ARM64) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(8,0,0) #elif defined(__AARCH64EL__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(8,0,0) #elif defined(__ARM_ARCH_7__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(7,0,0) #elif defined(__ARM_ARCH_7A__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(7,0,0) #elif defined(__ARM_ARCH_7R__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(7,0,0) #elif defined(__ARM_ARCH_7M__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(7,0,0) #elif defined(__ARM_ARCH_6K__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(6,0,0) #elif defined(__ARM_ARCH_6Z__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(6,0,0) #elif defined(__ARM_ARCH_6KZ__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(6,0,0) #elif defined(__ARM_ARCH_6T2__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(6,0,0) #elif defined(__ARM_ARCH_5TE__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(5,0,0) #elif defined(__ARM_ARCH_5TEJ__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(5,0,0) #elif defined(__ARM_ARCH_4T__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(4,0,0) #elif defined(__ARM_ARCH_4__) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(4,0,0) #elif defined(__ARM_ARCH) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(V,0,0) #elif defined(__TARGET_ARCH_ARM) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(V,0,0) #elif defined(__TARGET_ARCH_THUMB) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(V,0,0) #elif defined(_M_ARM) # define BOOST_ARCH_ARM BOOST_VERSION_NUMBER(V,0,0) ```