From 4d21fc53889a5878f852a765daac361046439dcd Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Fri, 12 Aug 2016 23:35:22 -0500 Subject: [PATCH] Add ability to disable inlining of functions Some build environments build each source file individually to .o files and then link after the fact. With inlined functions, this tends to just produce empty .o files, undefined symbol errors, and grumpy programmers like me. This change simply adds the option to disable inlining of functions so Handmade Math can function properly as a library unto itself. --- HandmadeMath.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/HandmadeMath.h b/HandmadeMath.h index 6a7c431..8b04942 100644 --- a/HandmadeMath.h +++ b/HandmadeMath.h @@ -49,6 +49,22 @@ #define HANDMADE_MATH_IMPLEMENTATION #define HANDMADE_MATH_NO_SSE + ========================================================================== + + To disable inlining functions, you MUST + + #define HANDMADE_MATH_NO_INLINE + + in EXACTLY one C or C++ file that includes this header, BEFORE the + include, like this: + + #define HANDMADE_MATH_IMPLEMENTATION + #define HANDMADE_MATH_CPP_MODE + #define HANDMADE_MATH_NO_INLINE + #include "HandmadeMath.h" + + All other files should just #include "HandmadeMath.h" without the #define. + Version History: 0.2 (*) Updated documentation (*) Better C compliance @@ -111,7 +127,9 @@ extern "C" #define HMMDEF extern #endif -#if _MSC_VER && !__INTEL_COMPILER +#ifdef HANDMADE_MATH_NO_INLINE +#define HINLINE +#elif _MSC_VER && !__INTEL_COMPILER #define HINLINE __inline #else #define HINLINE inline