Fixed astcenc.h for C builds and double definition of NOMINMAX #584
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Firstly, i could not determine if full C compatibility was intended for this repository, so i want to apologize if it was not.
issues
<astcenc.h>unconditionally includes<cstddef>and<cstdint>which are C++ exclusive headers.<astcenc.h>are not typedef'd to global scope which makes most struct and function definitions ill-formed in a C contextextern "C"is used unconditionally in<astcenc.h>withASTCENC_DYNAMIC_LIBRARYwhich is also invalid Cninja 1.11.1+MinGW UCRT64 gcc 15.1.0)These changes are ABI BREAKING since C++ name mangling/linkage for all API exposed functions in
<astcenc.h>get disabled with this commit.changes
<cstddef>and<cstdint>around#if defined(__cplusplus), use C compat versions otherwise<stdbool.h>for C buildsextern "c"only for C++ builds#define NOMINMAXinto a guard that prevents double definitionsPerhaps i should add a "ASTCENC_C_COMPAT" flag to the CMake build file to avoid a forced ABI change for all users?
I have tested building the library with these changes on both C and C++ compilers with success. I am open to any other approach that the maintainers prefer, if C compatibility IS intended :)