-
Notifications
You must be signed in to change notification settings - Fork 244
Implementation
For Visual C++, the projects make use of the default C++11/C++14 mode rather than /std:c++17
mode. The library does not make use of newer C++17 language & library features such as string_view
, static_assert
without a message, etc. although that may change in the future. The projects make use of /Wall
, /permissive-
, /Zc:__cplusplus
, and /analyze
to ensure a high-level of C++ conformance.
For clang/LLVM for Windows, there is a CMakeList.txt
provided to validate the code and ensure a high-level of conformance. This primarily means addressing warnings generated using /Wall -Wpedantic -Wextra
.
DirectXMath is written using standard Intel-style intrinsics, which should be portable to other compilers. The ARM and ARM64 codepaths use ARM-style intrinsics (earlier versions of the library used Visual C++ specific __n64
and __n128
), so these are also portable.
The DirectXMath library make use of two commonly implemented extensions to Standard C++:
- anonymous structs, which are widely supported and are part of the C11 standard. Note that the library also uses anonymous unions, but these are part of the C++ and C99 standard.
- #pragma once rather than old-style #define based guards, but are widely supported
Because of these, DirectXMath is not compatible with Visual C++'s
/Za
switch which enforces ISO C89 / C++11. It does work with/permissive-
.
- PascalCase for class names, methods, functions, and enums.
- camelCase for class member variables, struct members
- UPPERCASE for preprocessor defines (and nameless enums)
The library does not generally make use of Hungarian notation which as been deprecated for Win32 C++ APIs for many years, with the exception of a few uses of p
for pointers and sz
for strings.
The use of Standard C++ types is preferred including the fundamental types supplied by the language (i.e. int
, unsigned int
, size_t
, ptrdiff_t
, bool
, true
/false
, char
, wchar_t
) with the addition of the C99 fixed width types (i.e. uint32_t
, uint64_t
, intptr_t
, uintptr_t
, etc.)
Avoid using Windows "portability" types except when dealing directly with Win32 APIs: VOID
, UINT
, INT
, DWORD
, FLOAT
, BOOL
, TRUE
/FALSE
, WCHAR
, CONST
, etc.
As a low-level math library, DirectXMath does not make use of C++ exception handling or HRESULT
COM-style error values. Generally, parameter validation is limited to assert
macros.
The DirectXMath library makes extensive use of SAL2 annotations (_In_
, _Outptr_opt_
, etc.) which greatly improves the accuracy of the Visual C++ static code analysis (also known as PREFAST). The standard Windows headers #define
them all to empty strings if not building with /analyze
, so they have no effect on code-generation.
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v19
- GCC 10.5, 11.4, 12.3, 13.3, 14.2
- MinGW 12.2, 13.2
- Intel Classic Compiler
- Intel oneAPI Compiler
- CMake 3.20
DirectX Tool Kit for DirectX 11