Skip to content

Add prefix to problematic stb_truetype equal() func#905

Merged
RobLoach merged 1 commit intoImmediate-Mode-UI:masterfrom
rswinkle:prefix_stb_truetype_equal
Mar 1, 2026
Merged

Add prefix to problematic stb_truetype equal() func#905
RobLoach merged 1 commit intoImmediate-Mode-UI:masterfrom
rswinkle:prefix_stb_truetype_equal

Conversation

@rswinkle
Copy link
Contributor

I don't know how this function has lasted so long in such a widely used library but we are on the latest version of stb_truetype and it's still there.

It's such a small function and only used twice so I'm also fine with just eliminating it entirely but I figure just changing the name keeps it closer to upstream.

@sleeptightAnsiC
Copy link
Contributor

sleeptightAnsiC commented Mar 1, 2026

Is the lack of prefix causing any symbol conflicts in your code? I didn't found anything in Nuklear where this would be the case.

Shouldn't this be reported to STB upstream first? I feel a bit uneasy that you're trying to patch it here. Someone may overwrite your changes when bumping this file.

@sleeptightAnsiC
Copy link
Contributor

sleeptightAnsiC commented Mar 1, 2026

Someone may overwrite your changes when bumping this file.

If you take a look at git history of that file (git log -p -- src/stb_truetype.h) you'll notice this already has happened:

I'm afraid your patch will meet the same fate ;/

@rswinkle
Copy link
Contributor Author

rswinkle commented Mar 1, 2026

Is the lack of prefix causing any symbol conflicts in your code? I didn't found anything in Nuklear where this would be the case.

It's conflicting with my code not Nuklear or it would have been discovered much immediately. However, whether as stb_truetype alone, or as part of Nuklear, having a function named "equal" in a C library, especially a single header library, is problematic. Sure it's declared static and I could put it in a separate TU, but I tend to prefer unity builds, (or at least unity-ish builds), so that doesn't help. And honestly, I'm surprised someone even made a function so small that's used literally twice.

Shouldn't this be reported to STB upstream first? I feel a bit uneasy that you're trying to patch it here. Someone may overwrite your changes when bumping this file.
I'm afraid your patch will meet the same fate ;/

Theoretically, but stb_truetype hasn't been updated in almost 5 years so I wouldn't hold my breath for a new release.

Even if there were an update eventually, unless it's a significant fix/improvement there's no real need to update our local copy, and if it is worth it to update, and the people involved in updating forgot to keep the change, no big deal.
It can always be re-added if someone wants it, and having it in for all the time between now and then is still more than worth it.

Remember, no one forces developers to update Nuklear (and most developers using it seriously make local changes to libraries like Nuklear anyway), meaning if/when stb_truetype get's updated and this eventually possibly gets overwritten, they won't even notice even if it would affect them because they're not grabbing the latest version immediately just because it exists because updating means they have to re-apply all their changes again and handle any conflicts.

Anyway, long story short, I think it's worth changing, whether prefixing or eliminating it entirely.

Copy link
Contributor

@sleeptightAnsiC sleeptightAnsiC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just entered an upstream issue for this: nothings/stb#1898

I personally don't mind this being patched here. It's not a big deal.

@nothings
Copy link

nothings commented Mar 1, 2026

Yes, this is absolutely a bug that we will fix upstream as well.

Copy link
Contributor

@RobLoach RobLoach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equals(AWESOME);
// => true

@RobLoach RobLoach merged commit 9afa2ba into Immediate-Mode-UI:master Mar 1, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

4 participants