Add required headers to implementation section#3
Open
m4c0 wants to merge 2 commits intotsoding:masterfrom
Open
Add required headers to implementation section#3m4c0 wants to merge 2 commits intotsoding:masterfrom
m4c0 wants to merge 2 commits intotsoding:masterfrom
Conversation
This commit fixes the build of minirent if included by itself in a unit file containing only its implemention. ``` #define MINIRENT_IMPLEMENTATION #include "minirent.h" ``` Without this fix, there are compilation errors for `assert`, `calloc` and `snprintf`.
This uses the example (and GitHub Actions) as a "unit test" to confirm the header compiles on its own, without implicitly requiring its input unit to import anything else.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I was trying to use minirent in a niche gaming platform (sometimes called Windows) and it failed to build on its own if I had a file containing only these lines:
It required some common C library functions like
assert,callocandsnprintf. Since they are not required in non-Windows platforms, I presume it is ok to add the required includes to the implementation block.I also tweaked the example to move the minirent header to the top of the
lsexample, acting both as a "test" for the implementation block compilation, and to show future users that minirent is self-contained.