Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stb_image.h in the project is tech debt #673

Open
mulle-nat opened this issue Aug 25, 2024 · 5 comments
Open

stb_image.h in the project is tech debt #673

mulle-nat opened this issue Aug 25, 2024 · 5 comments

Comments

@mulle-nat
Copy link
Contributor

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>
#endif

This 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@mulle-nat and others