Fix Windows/MinGW build: reserved errno parameter name, missing err.h - #107
Open
doomfrawen wants to merge 1 commit into
Open
Fix Windows/MinGW build: reserved errno parameter name, missing err.h#107doomfrawen wants to merge 1 commit into
doomfrawen wants to merge 1 commit into
Conversation
- usage(FILE *stream, int errno) uses the reserved identifier 'errno' as a parameter name. MinGW's <errno.h> (pulled in transitively) defines errno as a macro expanding to a function call, which mangles this declaration/definition and produces 'passing argument 2 of usage makes pointer from integer without a cast'. Renamed to exit_code. - nfc-utils.h/.c include <err.h>, a BSD/glibc-only header not provided by MinGW-w64. The only function actually used from it is warnx() (via the DBG/WARN/ERR macros), so on _WIN32 this adds a small static inline warnx() shim instead, and drops the redundant second #include <err.h> in nfc-utils.c (nfc-utils.h already provides it).
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.
Building mfoc for native Windows via MSYS2 MinGW64 against a working libnfc, ./configure succeeds but the build fails on two portability issues:
1.
src/mfoc.c/src/mfoc.h—usage(FILE *stream, int errno)uses the reserved identifiererrnoas a parameter name. MinGW's<errno.h>(pulled in transitively) defineserrnoas a macro expanding to a function call, which mangles this declaration and producespassing argument 2 of usage makes pointer from integer without a cast. Renamed the parameter toexit_code(also updated the one call site,exit(errno)->exit(exit_code)).2.
src/nfc-utils.h/src/nfc-utils.c— includes<err.h>, a BSD/glibc-only header not shipped by MinGW-w64, so the build fails witherr.h: No such file or directory. The only thing actually used from it iswarnx()(via theDBG/WARN/ERRmacros), so this adds a smallstatic inline warnx()shim under#ifdef _WIN32instead of the header, and drops the redundant second#include <err.h>in nfc-utils.c (nfc-utils.h already brings it in).Both changes are additive/platform-scoped and don't touch non-Windows behavior.