瀏覽代碼

add 'included' defines to all sokol headers for better error messages when included are missing

Andre Weissflog 6 年之前
父節點
當前提交
7f4df6cd44
共有 7 個文件被更改,包括 29 次插入0 次删除
  1. 11 0
      imgui/sokol_gfx_imgui.h
  2. 2 0
      sokol_app.h
  3. 2 0
      sokol_args.h
  4. 2 0
      sokol_audio.h
  5. 3 0
      sokol_gfx.h
  6. 2 0
      sokol_time.h
  7. 7 0
      util/README.md

+ 11 - 0
imgui/sokol_gfx_imgui.h

@@ -126,6 +126,10 @@
 #include <stdint.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdbool.h>
 
 
+#if !defined(SOKOL_GFX_INCLUDED)
+#error "Please include sokol_gfx.h before sokol_gfx_imgui.h"
+#endif
+
 #if defined(__cplusplus)
 #if defined(__cplusplus)
 extern "C" {
 extern "C" {
 #endif
 #endif
@@ -578,6 +582,13 @@ SOKOL_API_DECL void sg_imgui_draw_capture_window(sg_imgui_t* ctx);
 
 
 /*=== IMPLEMENTATION =========================================================*/
 /*=== IMPLEMENTATION =========================================================*/
 #if defined SOKOL_IMPL
 #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 <string.h>
 #include <stdio.h>      /* snprintf */
 #include <stdio.h>      /* snprintf */
 
 

+ 2 - 0
sokol_app.h

@@ -382,6 +382,7 @@
         3. This notice may not be removed or altered from any source
         3. This notice may not be removed or altered from any source
         distribution.
         distribution.
 */
 */
+#define SOKOL_APP_INCLUDED (1)
 #include <stdint.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdbool.h>
 
 
@@ -659,6 +660,7 @@ SOKOL_API_DECL int sapp_run(const sapp_desc* desc);
 
 
 /*-- IMPLEMENTATION ----------------------------------------------------------*/
 /*-- IMPLEMENTATION ----------------------------------------------------------*/
 #ifdef SOKOL_IMPL
 #ifdef SOKOL_IMPL
+#define SOKOL_APP_IMPL_INCLUDED (1)
 
 
 #ifdef _MSC_VER
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(push)

+ 2 - 0
sokol_args.h

@@ -232,6 +232,7 @@
         3. This notice may not be removed or altered from any source
         3. This notice may not be removed or altered from any source
         distribution.
         distribution.
 */
 */
+#define SOKOL_ARGS_INCLUDED (1)
 #include <stdint.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdbool.h>
 
 
@@ -281,6 +282,7 @@ SOKOL_API_DECL const char* sargs_value_at(int index);
 
 
 /*--- IMPLEMENTATION ---------------------------------------------------------*/
 /*--- IMPLEMENTATION ---------------------------------------------------------*/
 #ifdef SOKOL_IMPL
 #ifdef SOKOL_IMPL
+#define SOKOL_ARGS_IMPL_INCLUDED (1)
 #include <string.h> /* memset, strcmp */
 #include <string.h> /* memset, strcmp */
 
 
 #if defined(__EMSCRIPTEN__)
 #if defined(__EMSCRIPTEN__)

+ 2 - 0
sokol_audio.h

@@ -352,6 +352,7 @@
         3. This notice may not be removed or altered from any source
         3. This notice may not be removed or altered from any source
         distribution.
         distribution.
 */
 */
+#define SOKOL_AUDIO_INCLUDED (1)
 #include <stdint.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdbool.h>
 
 
@@ -397,6 +398,7 @@ SOKOL_API_DECL int saudio_push(const float* frames, int num_frames);
 
 
 /*=== IMPLEMENTATION =========================================================*/
 /*=== IMPLEMENTATION =========================================================*/
 #ifdef SOKOL_IMPL
 #ifdef SOKOL_IMPL
+#define SOKOL_AUDIO_IMPL_INCLUDED (1)
 #include <string.h> /* memset, memcpy */
 #include <string.h> /* memset, memcpy */
 
 
 #ifndef SOKOL_API_IMPL
 #ifndef SOKOL_API_IMPL

+ 3 - 0
sokol_gfx.h

@@ -406,6 +406,7 @@
         3. This notice may not be removed or altered from any source
         3. This notice may not be removed or altered from any source
         distribution.
         distribution.
 */
 */
+#define SOKOL_GFX_INCLUDED (1)
 #include <stdint.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdbool.h>
 
 
@@ -1749,6 +1750,8 @@ SOKOL_API_DECL void sg_apply_uniform_block(sg_shader_stage stage, int ub_index,
 
 
 /*--- IMPLEMENTATION ---------------------------------------------------------*/
 /*--- IMPLEMENTATION ---------------------------------------------------------*/
 #ifdef SOKOL_IMPL
 #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))
 #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"
 #error "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL or SOKOL_DUMMY_BACKEND"
 #endif
 #endif

+ 2 - 0
sokol_time.h

@@ -79,6 +79,7 @@
         3. This notice may not be removed or altered from any source
         3. This notice may not be removed or altered from any source
         distribution.
         distribution.
 */
 */
+#define SOKOL_TIME_INCLUDED (1)
 #include <stdint.h>
 #include <stdint.h>
 
 
 #ifndef SOKOL_API_DECL
 #ifndef SOKOL_API_DECL
@@ -105,6 +106,7 @@ SOKOL_API_DECL double stm_ns(uint64_t ticks);
 
 
 /*-- IMPLEMENTATION ----------------------------------------------------------*/
 /*-- IMPLEMENTATION ----------------------------------------------------------*/
 #ifdef SOKOL_IMPL
 #ifdef SOKOL_IMPL
+#define SOKOL_TIME_IMPL_INCLUDED (1)
 #include <string.h> /* memset */
 #include <string.h> /* memset */
 
 
 #ifndef SOKOL_API_IMPL
 #ifndef SOKOL_API_IMPL

+ 7 - 0
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.