-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 int -> uint warning #2611
fix int -> uint warning #2611
Conversation
Could you post the complete warning message and platform details? |
warnings, build with Android Studio on Windows10
|
src/os.cc
Outdated
@@ -218,7 +218,7 @@ int buffered_file::fileno() const { | |||
|
|||
#if FMT_USE_FCNTL | |||
file::file(cstring_view path, int oflag) { | |||
int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; | |||
unsigned int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; |
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.
This won't work on Windows where mode is int
. The solution would be to use mode_t
here and define it near the constants in https://github.com/fmtlib/fmt/blob/master/src/os.cc#L32-L43
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.
Wouldn't warning disappear if constexpr
is used, so that the compiler will have to substitute the value and not being afraid of narrowing. Then it could be constexpr auto
I guess.
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.
I don't think constexpr
is relevant here and auto
will just result in int
. Note that the warning is not on this line.
src/os.cc
Outdated
# ifndef mode_t | ||
# define mode_t int | ||
# 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.
For win32:
#ifndef __MINGW32__
using mode_t = int;
#endif
Mingw always defines the Maybe define the type like this: #ifdef _WIN32
# ifdef __MINGW32__
using fmt_mode_t = _mode_t;
# else
using fmt_mode_t = int;
# endif
#else
using fmt_mode_t = mode_t;
#endif And then use the |
src/os.cc
Outdated
# ifdef __MINGW32__ | ||
# define _SH_DENYNO 0x40 | ||
# else | ||
using mode_t = int; |
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.
Let's put mode_t
in the fmt::detail
namespace and in the file
constructor add using namespace fmt::detail
. Then it will pick up our fmt::detail::mode_t
if available and the global one otherwise. Also no need to check for __MINGW32__
.
Thank you |
in my project i tried to mute warnings from fmt, but this one persist, should be harmless.