From 58d2f19409548b94edb141e76220fc07706ea5ab Mon Sep 17 00:00:00 2001 From: DP Date: Fri, 13 Mar 2026 10:13:53 +0100 Subject: [PATCH] Fix multiple definition errors by gating implementation behind THIRTEEN_IMPLEMENTATION. Currently thirteen.h contains both declarations and implementations unconditionally. When the header is included in multiple translation units, this can lead to multiple definition linker errors. Usage: define THIRTEEN_IMPLEMENTATION in exactly one .c/.cpp file before including thirteen.h; include the header normally everywhere else. --- Examples/Mandelbrot/main.cpp | 1 + Examples/Minesweeper/main.cpp | 1 + Examples/Simple/main.cpp | 1 + thirteen.h | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Examples/Mandelbrot/main.cpp b/Examples/Mandelbrot/main.cpp index aee0f80..064058a 100644 --- a/Examples/Mandelbrot/main.cpp +++ b/Examples/Mandelbrot/main.cpp @@ -1,5 +1,6 @@ #define _CRT_SECURE_NO_WARNINGS // for STB +#define THIRTEEN_IMPLEMENTATION #include "../../thirteen.h" #include diff --git a/Examples/Minesweeper/main.cpp b/Examples/Minesweeper/main.cpp index be78e79..c733601 100644 --- a/Examples/Minesweeper/main.cpp +++ b/Examples/Minesweeper/main.cpp @@ -1,5 +1,6 @@ #define _CRT_SECURE_NO_WARNINGS // for STB +#define THIRTEEN_IMPLEMENTATION #include "../../thirteen.h" #include diff --git a/Examples/Simple/main.cpp b/Examples/Simple/main.cpp index 59d2d9c..69b966f 100644 --- a/Examples/Simple/main.cpp +++ b/Examples/Simple/main.cpp @@ -1,5 +1,6 @@ #define _CRT_SECURE_NO_WARNINGS // for STB +#define THIRTEEN_IMPLEMENTATION #include "../../thirteen.h" #include diff --git a/thirteen.h b/thirteen.h index 3e54d94..03a60fd 100644 --- a/thirteen.h +++ b/thirteen.h @@ -164,7 +164,7 @@ namespace Thirteen } // ========== Implementation ========== - +#ifdef THIRTEEN_IMPLEMENTATION namespace Thirteen { @@ -2351,3 +2351,4 @@ namespace Thirteen Internal::Pixels = nullptr; } } +#endif // THIRTEEN_IMPLEMENTATION