aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2019-03-09 13:50:28 +0100
committerAndre Weissflog <floooh@gmail.com>2019-03-09 13:50:28 +0100
commit7f4df6cd44875ef2b5912592c3c8d0c2401b5660 (patch)
treebed76ed72db8298472341af7ead86f12b8769755
parent29ce2f7eedc74f260da2aaa326fbd8b9ce3c20d5 (diff)
add 'included' defines to all sokol headers for better error messages when included are missing
-rw-r--r--imgui/sokol_gfx_imgui.h11
-rw-r--r--sokol_app.h2
-rw-r--r--sokol_args.h2
-rw-r--r--sokol_audio.h2
-rw-r--r--sokol_gfx.h3
-rw-r--r--sokol_time.h2
-rw-r--r--util/README.md7
7 files changed, 29 insertions, 0 deletions
diff --git a/imgui/sokol_gfx_imgui.h b/imgui/sokol_gfx_imgui.h
index 5015e203..5e517451 100644
--- a/imgui/sokol_gfx_imgui.h
+++ b/imgui/sokol_gfx_imgui.h
@@ -126,6 +126,10 @@
#include <stdint.h>
#include <stdbool.h>
+#if !defined(SOKOL_GFX_INCLUDED)
+#error "Please include sokol_gfx.h before sokol_gfx_imgui.h"
+#endif
+
#if defined(__cplusplus)
extern "C" {
#endif
@@ -578,6 +582,13 @@ SOKOL_API_DECL void sg_imgui_draw_capture_window(sg_imgui_t* ctx);
/*=== IMPLEMENTATION =========================================================*/
#if defined SOKOL_IMPL
+#if !defined(SOKOL_GFX_IMPL_INCLUDED)
+#error "Please include the sokol_gfx.h implementation before the sokol_gfx_imgui.h implementation"
+#endif
+#if !defined(IMGUI_VERSION)
+#error "Please include imgui.h before the sokol_gfx_imgui.h implementation"
+#endif
+
#include <string.h>
#include <stdio.h> /* snprintf */
diff --git a/sokol_app.h b/sokol_app.h
index 4ee51f52..9d0c1e74 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -382,6 +382,7 @@
3. This notice may not be removed or altered from any source
distribution.
*/
+#define SOKOL_APP_INCLUDED (1)
#include <stdint.h>
#include <stdbool.h>
@@ -659,6 +660,7 @@ SOKOL_API_DECL int sapp_run(const sapp_desc* desc);
/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_IMPL
+#define SOKOL_APP_IMPL_INCLUDED (1)
#ifdef _MSC_VER
#pragma warning(push)
diff --git a/sokol_args.h b/sokol_args.h
index e75c7ad5..918b55b4 100644
--- a/sokol_args.h
+++ b/sokol_args.h
@@ -232,6 +232,7 @@
3. This notice may not be removed or altered from any source
distribution.
*/
+#define SOKOL_ARGS_INCLUDED (1)
#include <stdint.h>
#include <stdbool.h>
@@ -281,6 +282,7 @@ SOKOL_API_DECL const char* sargs_value_at(int index);
/*--- IMPLEMENTATION ---------------------------------------------------------*/
#ifdef SOKOL_IMPL
+#define SOKOL_ARGS_IMPL_INCLUDED (1)
#include <string.h> /* memset, strcmp */
#if defined(__EMSCRIPTEN__)
diff --git a/sokol_audio.h b/sokol_audio.h
index 210e47fc..5bdcdb65 100644
--- a/sokol_audio.h
+++ b/sokol_audio.h
@@ -352,6 +352,7 @@
3. This notice may not be removed or altered from any source
distribution.
*/
+#define SOKOL_AUDIO_INCLUDED (1)
#include <stdint.h>
#include <stdbool.h>
@@ -397,6 +398,7 @@ SOKOL_API_DECL int saudio_push(const float* frames, int num_frames);
/*=== IMPLEMENTATION =========================================================*/
#ifdef SOKOL_IMPL
+#define SOKOL_AUDIO_IMPL_INCLUDED (1)
#include <string.h> /* memset, memcpy */
#ifndef SOKOL_API_IMPL
diff --git a/sokol_gfx.h b/sokol_gfx.h
index d6029c2a..7221143b 100644
--- a/sokol_gfx.h
+++ b/sokol_gfx.h
@@ -406,6 +406,7 @@
3. This notice may not be removed or altered from any source
distribution.
*/
+#define SOKOL_GFX_INCLUDED (1)
#include <stdint.h>
#include <stdbool.h>
@@ -1749,6 +1750,8 @@ SOKOL_API_DECL void sg_apply_uniform_block(sg_shader_stage stage, int ub_index,
/*--- IMPLEMENTATION ---------------------------------------------------------*/
#ifdef SOKOL_IMPL
+#define SOKOL_GFX_IMPL_INCLUDED (1)
+
#if !(defined(SOKOL_GLCORE33)||defined(SOKOL_GLES2)||defined(SOKOL_GLES3)||defined(SOKOL_D3D11)||defined(SOKOL_METAL)||defined(SOKOL_DUMMY_BACKEND))
#error "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL or SOKOL_DUMMY_BACKEND"
#endif
diff --git a/sokol_time.h b/sokol_time.h
index 45c1c2f9..a1c8bdd0 100644
--- a/sokol_time.h
+++ b/sokol_time.h
@@ -79,6 +79,7 @@
3. This notice may not be removed or altered from any source
distribution.
*/
+#define SOKOL_TIME_INCLUDED (1)
#include <stdint.h>
#ifndef SOKOL_API_DECL
@@ -105,6 +106,7 @@ SOKOL_API_DECL double stm_ns(uint64_t ticks);
/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_IMPL
+#define SOKOL_TIME_IMPL_INCLUDED (1)
#include <string.h> /* memset */
#ifndef SOKOL_API_IMPL
diff --git a/util/README.md b/util/README.md
new file mode 100644
index 00000000..482a3896
--- /dev/null
+++ b/util/README.md
@@ -0,0 +1,7 @@
+# Sokol Utility Headers
+
+These are optional utility headers on top of the Sokol headers. Unlike the
+'core headers' they are not standalone, and usually do not contain
+platform specific code.
+
+FIXME: overview of the headers, and general usage instructions.