bkaradzic / bimg

Image library.
BSD 2-Clause "Simplified" License
327 stars 268 forks source link

Fix emscripten builds by correcting `ctype.h` include. #51

Closed bdero closed 3 years ago

bdero commented 3 years ago

The emscripten compat headers work by transparently augmenting imports and including the original headers via #include_next. The search path for emscripten places system/include/compat before system/include, and so importing with compat/ctype.h causes the preprocessor to skip over system/include/compat and land the search cursor on system/include, which then causes the subsequent #include_next <ctype.h> lookup to fail while processing the compat header.

Fixes emscripten-core/emscripten#13109. Fixes bkaradzic/bgfx#2336.

bdero commented 3 years ago

One caveat here is that I'm not sure how importing via compat/ctype.h worked at some point in the past. The compat header hasn't changed for 7 years and this include hasn't changed since the bimg repo was created 4 years ago.

My best guess is that emscripten removed a 3rd/redundant search path at some point which offered the same contents as system/include, and so importing via `compat/ctype.h' just happened to work unintentionally.

bkaradzic commented 3 years ago

SInce you're already there... ctype.h was needed for tinyexr. What happens if you completely remove it? If it's not needed anymore it would be better to not be there. Or if it's needed just add comment what's needed.

bdero commented 3 years ago

Yup, I don't think it's needed anymore. Just tried removing it and it builds: #52

bkaradzic commented 3 years ago

Cool! Thanks!