-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix warnings on Windows and reimplement err and errx as functions #193
Conversation
mingw-w64's stdio.h header already defines fseeko Signed-off-by: Christopher Degawa <ccom@randomderp.com>
gcc warns against comparing size_t against -1 or checking if it's less than zero as the first may be due to incorrect assumptions and the second will always return false. Signed-off-by: Christopher Degawa <ccom@randomderp.com>
These functions are based on the manpage for err(3) and errx(3), minus the condition for the fmt to be NULL on the consideration that none of the calls to them contain NULL as the fmt. Online man page that was consulted: https://docs.oracle.com/cd/E36784_01/html/E36874/errx-3c.html Signed-off-by: Christopher Degawa <ccom@randomderp.com>
#include <errno.h> | ||
#include <stdarg.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If wanted, I can move these includes up to an else branch for the #if !defined(WIN32) && !defined(_AIX)
condition. I've only included them here for no particular reaso
#if defined(_WIN32) && !defined(fseeko) | ||
# define fseeko fseek | ||
# define ftello ftell | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A potentially more robust check would be to also add && !defined(ftello)
and undef both before defining them, but I wasn't sure if adding more lines for these two macros would be desirable
This looks good to me for Darwin, Debian 11, and MingW (gcc 9.2.0) on Windows10. Thank you for your help and contribution! |
See: #192
Fixes some warnings produced by mingw-w64 gcc regarding signed<->unsigned comparison and comparing against less than 0 for unsigned numbers, along with redefined macros.
Also reimplements the macros err and errx as functions based on the man page description, minus a few sections due to those conditions not being met in any of the calls.
Confirmed this to work on both linux with
gcc (GCC) 12.2.0
andx86_64-w64-mingw32-gcc (GCC) 12.2.0
from archlinux and fromcc.exe (Rev4, Built by MSYS2 project) 12.2.0
from ucrt64 from MSYS2.To reproduce on a linux machine with mingw-w64 gcc and meson installed