Skip to content
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(Clang CodeGen): remove warnings #582

Closed

Conversation

yumetodo
Copy link
Contributor

./fmt/fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas]
# pragma intrinsic(_BitScanReverse)
         ^
1 warning generated.
format.cc In file included from fmt\fmt\format.cc:28:
fmt\fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas]
# pragma intrinsic(_BitScanReverse)
         ^
fmt\fmt\format.cc(165,17): warning : 'strerror' is deprecated: This
function or variable may be unsafe. Consider using strerror_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for
details. [-Wdeprecated-declarations]
      buffer_ = strerror(error_code_);
                ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(178,24) :  note: 'strerror' has been explicitly marked deprecated here
_ACRTIMP char* __cdecl strerror(
                       ^
fmt\fmt\format.cc(78,37): warning : unused function 'strerror_s' [-Wunused-function]
static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
                                    ^
3 warnings generated.

./fmt/fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas]
# pragma intrinsic(_BitScanReverse)
         ^
1 warning generated.
format.cc In file included from fmt\fmt\format.cc:28:
fmt\fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas]
# pragma intrinsic(_BitScanReverse)
         ^
fmt\fmt\format.cc(165,17): warning : 'strerror' is deprecated: This
function or variable may be unsafe. Consider using strerror_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for
details. [-Wdeprecated-declarations]
      buffer_ = strerror(error_code_);
                ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(178,24) :  note: 'strerror' has been explicitly marked deprecated here
_ACRTIMP char* __cdecl strerror(
                       ^
fmt\fmt\format.cc(78,37): warning : unused function 'strerror_s' [-Wunused-function]
static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
                                    ^
3 warnings generated.
Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR! Looks good but could you replace -Wunused-function suppression with calling the dummy strerror_s function as it is done for strerror_r in

strerror_r(0, FMT_NULL, "");
? It is a bit cleaner an the compiler will optimize the call away.

@yumetodo
Copy link
Contributor Author

@vitaut I've fixed that. However, it is too dirty to use dummy function call to remove -Wunused-function warnings. I think.

@foonathan
Copy link
Contributor

I usually cast the function to void, like you would do for unused variables.

@vitaut
Copy link
Contributor

vitaut commented Oct 14, 2017

I usually cast the function to void, like you would do for unused variables.

Like this

(void)strerror_s;

without actually calling it?

@foonathan
Copy link
Contributor

Yes

@yumetodo
Copy link
Contributor Author

@foonathan out of the question

1>format.cc
1>fmt\fmt\format.cc(187,5): error : address of overloaded function 'strerror_s' cannot be cast to type 'void'
1>          (void)strerror_s;
1>           ^~~~
1>fmt\fmt\format.cc(78,37) :  note: candidate function
1>static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
1>                                    ^
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(183,14) :  note: candidate function
1>    errno_t, strerror_s,
1>             ^
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(41,30) :  note: candidate function
1>    _ACRTIMP errno_t __cdecl strerror_s(
1>                             ^
1>1 error generated.

@foonathan
Copy link
Contributor

Yeah, okay ːD

@yumetodo
Copy link
Contributor Author

yumetodo commented Oct 14, 2017

We should consider [[maybe_unused]](C++17) or __attribute__ ((unused))(GCC extension)

#if FMT_HAS_CPP_ATTRIBUTE(maybe_unused)
# define FMT_HAS_CXX17_ATTRIBUTE_MAYBE_UNUSED
#elif defined(_MSVC_LANG) && _MSVC_LANG > 201402
# define FMT_HAS_CXX17_ATTRIBUTE_MAYBE_UNUSED
#endif

#ifdef FMT_HAS_CXX17_ATTRIBUTE_MAYBE_UNUSED
# define FMT_MAYBE_UNUSED [[maybe_unused]]
#elif defined(__GNUC__)
# define FMT_MAYBE_UNUSED __attribute__ ((unused))
#else
#define FMT_MAYBE_UNUSED
#endif
FMT_MAYBE_UNUSED static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
  return fmt::internal::Null<>();
}

@vitaut
Copy link
Contributor

vitaut commented Oct 14, 2017

We should consider [maybe_unused] or attribute ((unused))(GCC extension)

Good idea.

@yumetodo
Copy link
Contributor Author

@vitaut implement in d2ba420 .

@vitaut
Copy link
Contributor

vitaut commented Oct 15, 2017

Merged in 708d950, thanks!

@vitaut vitaut closed this Oct 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants