-
Notifications
You must be signed in to change notification settings - Fork 794
Description
LOL, I always wanted to create a bug report with tech debt in the title. Now here's why.
The "stb_image.h" version in nanovg is nine years old, and a couple of revisions older than the current version.
nanovg.c uses it like this:
#ifndef NVG_NO_STB
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#endif
...
#ifndef NVG_NO_STB
int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags)
{So, if you define NVG_NO_STB, you get no image functionality. You can't have your own version or get the symbols from a different library that also uses "stb_image.h".
It would be better, if the inclusion code would look like this:
#ifndef NVG_NO_STB
# ifndef NVG_NO_STB_IMAGE_IMPLEMENTATION
# define STB_IMAGE_IMPLEMENTATION
# endif
# include <stb_image.h>
#endifThis way you could avoid creating possibly duplicate symbols when building nanovg (by setting NVG_NO_STB_IMAGE_IMPLEMENTATION) and you can still avoid "stb_image.h" altogether with NVG_NO_STB as before.
The # include <stb_image.h> will look for an installed "stb_image.h" before considering the local one.