From ba739e54edea02c807cf6bd93e1b19bad5bfa726 Mon Sep 17 00:00:00 2001 From: Fabian Giesen Date: Fri, 2 Jul 2021 22:31:41 -0700 Subject: [PATCH] readme: Add "how to use these libs" section Try to be a bit more explicit still. Fixes issue #903, or so I hope. --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 0fadc68..deace3c 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,24 @@ Total lines of C code: 56524 FAQ --- +#### How do I use these libraries? + +The idea behind single-header file libraries is that they're easy to distribute and deploy +because all the code is contained in a single file. By default, the .h files in here act as +their own header files, i.e. they declare the functions contained in the file but don't +actually result in any code getting compiled. + +So in addition, you should select _exactly one_ C/C++ source file that actually instantiates +the code, preferably a file you're not editing frequently. This file should define a +specific macro (this is documented per-library) to actually enable the function definitions. +For example, to use stb_image, you should have exactly one C/C++ file that doesn't +include stb_image.h regularly, but instead does + + #define STB_IMAGE_IMPLEMENTATION + #include "stb_image.h" + +The right macro to define is pointed out right at the top of each of these libraries. + #### What's the license? These libraries are in the public domain. You can do anything you