From ade80556b8edf1a25de356906c3e06e8c0ced6ff Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 20 Jan 2022 18:00:15 -0800 Subject: [PATCH] Updated Implementation (markdown) --- Implementation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Implementation.md b/Implementation.md index 214155c..f9e2f26 100644 --- a/Implementation.md +++ b/Implementation.md @@ -142,6 +142,10 @@ SpriteBatch::~SpriteBatch() = default; # Calling-conventions Public methods in the library are explicitly marked ``__cdecl`` to ensure consistent behavior no matter what the client code is using. Internally it is not specified as it's assumed from the default setting except where ``XM_VECTORCALL`` is utilized (see the _DirectXMath_ section below). Public ``inline`` functions do not need to be explicitly marked ``__cdecl``. +> This generally only matters for 32-bit (x86) platforms which have a potential mix of many calling conventions (``__stdcall``, ``__cdecl``, ``__fastcall``, or ``__vectorcall``). For X64, ARM, and ARM64 they all generally just use one calling convention (``__fastcall``). For 64-bit (x64 native), the ``__cdecl`` is interpreted by the compiler as an alias for ``__fastcall`` so it's the same as annotating them with the default calling convention. It's still important to annotate exported public functions for x64 because it's possible to build the client using ``/Gv`` which assumes ``__vectorcall`` if nothing is specified. + +> Note that annotation for the calling-convention only has to be on the function declaration/prototype as the definition will pick it up implicilty. + The ``std::function`` is used for callbacks as a general pattern so that client code can provide function pointers, lambdas, functors, etc. To support building with a mix of calling conventions, we need to annotate the ``std::function`` correctly. ```cpp