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

Visual Studio w/ Clang will not compile #190

Closed
LukeMauldin opened this issue Mar 29, 2016 · 3 comments
Closed

Visual Studio w/ Clang will not compile #190

LukeMauldin opened this issue Mar 29, 2016 · 3 comments

Comments

@LukeMauldin
Copy link

Multiple compile errors with Visual Studio 2015 Update 2 RC and Clang.

Steps to reproduce:
Create new project: Templates -> Visual C++ -> Cross Platform -> Dynamic Library (windows) for Clang 3.7 with Microsoft Code Generation

Add spdlog files into project and try to compile and include "spdlog.h".
Output of errors

1>------ Build started: Project: Clangspdlog, Configuration: Debug Win32 ------
1>  dllmain.cpp
1>  format.cc
1>  In file included from spdlog\details\format.cc:28:
1>spdlog\details/format.h(93,10): warning : unknown pragma ignored [-Wunknown-pragmas]
1>  # pragma intrinsic(_BitScanReverse)
1>           ^
1>spdlog\details/format.h(938,10): warning : 'FMT_BUILTIN_CLZ' macro redefined [-Wmacro-redefined]
1>  # define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
1>           ^
1>  spdlog\details/format.h(100,10) :  note: previous definition is here
1>  # define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)
1>           ^
1>spdlog\details/format.h(942,10): warning : 'FMT_BUILTIN_CLZLL' macro redefined [-Wmacro-redefined]
1>  # define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
1>           ^
1>  spdlog\details/format.h(121,10) :  note: previous definition is here
1>  # define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n)
1>           ^
1>spdlog\details/format.cc(80,37): error : redefinition of 'strerror_r'
1>  static inline fmt::internal::Null<> strerror_r(int, char *, ...) {
1>                                      ^
1>  spdlog\details/format.cc(80,37) :  note: previous definition is here
1>  static inline fmt::internal::Null<> strerror_r(int, char *, ...) {
1>                                      ^
1>spdlog\details/format.cc(83,37): error : redefinition of 'strerror_s'
1>  static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
1>                                      ^
1>  spdlog\details/format.cc(83,37) :  note: previous definition is here
1>  static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
1>                                      ^
1>spdlog\details/format.cc(93,12): error : redefinition of 'fmt_snprintf'
1>  inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
1>             ^
1>  spdlog\details/format.cc(93,12) :  note: previous definition is here
1>  inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
1>             ^
1>spdlog\details/format.cc(112,8): error : redefinition of 'IntChecker'
1>  struct IntChecker {
1>         ^
1>  spdlog\details/format.cc(112,8) :  note: previous definition is here
1>  struct IntChecker {
1>         ^
1>spdlog\details/format.cc(124,8): error : redefinition of 'fmt::(anonymous namespace)::IntChecker<true>'
1>  struct IntChecker<true> {
1>         ^~~~~~~~~~~~~~~~
1>  spdlog\details/format.cc(124,8) :  note: previous definition is here
1>  struct IntChecker<true> {
1>         ^
1>spdlog\details/format.cc(134,12): error : redefinition of 'RESET_COLOR'
1>  const char RESET_COLOR[] = "\x1b[0m";
1>             ^
1>  spdlog\details/format.cc(134,12) :  note: previous definition is here
1>  const char RESET_COLOR[] = "\x1b[0m";
1>             ^
1>spdlog\details/format.cc(147,5): error : redefinition of 'safe_strerror'
1>  int safe_strerror(
1>      ^
1>  spdlog\details/format.cc(147,5) :  note: previous definition is here
1>  int safe_strerror(
1>      ^
1>spdlog\details/format.cc(190,23): 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]
1>              buffer_ = strerror(error_code_);
1>                        ^
1>  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
1>  _ACRTIMP char* __cdecl strerror(
1>                         ^
1>spdlog\details/format.cc(206,6): error : redefinition of 'format_error_code'
1>  void format_error_code(fmt::Writer &out, int error_code,
1>       ^
1>  spdlog\details/format.cc(206,6) :  note: previous definition is here
1>  void format_error_code(fmt::Writer &out, int error_code,
1>       ^
1>spdlog\details/format.cc(224,6): error : redefinition of 'report_error'
1>  void report_error(FormatFunc func,
1>       ^
1>  spdlog\details/format.cc(224,6) :  note: previous definition is here
1>  void report_error(FormatFunc func,
1>       ^
1>spdlog\details/format.cc(235,7): error : redefinition of 'IsZeroInt'
1>  class IsZeroInt : public fmt::internal::ArgVisitor<IsZeroInt, bool> {
1>        ^
1>  spdlog\details/format.cc(235,7) :  note: previous definition is here
1>  class IsZeroInt : public fmt::internal::ArgVisitor<IsZeroInt, bool> {
1>        ^
1>spdlog\details/format.cc(245,7): error : redefinition of 'WidthHandler'
1>  class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
1>        ^
1>  spdlog\details/format.cc(245,7) :  note: previous definition is here
1>  class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
1>        ^
1>spdlog\details/format.cc(272,7): error : redefinition of 'PrecisionHandler'
1>  class PrecisionHandler :
1>        ^
1>  spdlog\details/format.cc(272,7) :  note: previous definition is here
1>  class PrecisionHandler :
1>        ^
1>spdlog\details/format.cc(289,7): error : redefinition of 'ArgConverter'
1>  class ArgConverter : public fmt::internal::ArgVisitor<ArgConverter<T>, void> {
1>        ^
1>  spdlog\details/format.cc(289,7) :  note: previous definition is here
1>  class ArgConverter : public fmt::internal::ArgVisitor<ArgConverter<T>, void> {
1>        ^
1>spdlog\details/format.cc(337,7): error : redefinition of 'CharConverter'
1>  class CharConverter : public fmt::internal::ArgVisitor<CharConverter, void> {
1>        ^
1>  spdlog\details/format.cc(337,7) :  note: previous definition is here
1>  class CharConverter : public fmt::internal::ArgVisitor<CharConverter, void> {
1>        ^
1>spdlog\details/format.cc(357,7): error : redefinition of 'PrintfArgFormatter'
1>  class PrintfArgFormatter :
1>        ^
1>  spdlog\details/format.cc(357,7) :  note: previous definition is here
1>  class PrintfArgFormatter :
1>        ^
1>spdlog\details/format.cc(429,33): error : redefinition of 'init'
1>  FMT_FUNC void fmt::SystemError::init(
1>                                  ^
1>  spdlog\details/format.cc(429,33) :  note: previous definition is here
1>  FMT_FUNC void fmt::SystemError::init(
1>                                  ^
1>spdlog\details/format.cc(439,38): error : redefinition of 'format_float'
1>  int fmt::internal::CharTraits<char>::format_float(
1>                                       ^
1>  spdlog\details/format.cc(439,38) :  note: previous definition is here
1>  int fmt::internal::CharTraits<char>::format_float(
1>                                       ^
1>spdlog\details/format.cc(453,41): error : redefinition of 'format_float'
1>  int fmt::internal::CharTraits<wchar_t>::format_float(
1>                                          ^
1>  spdlog\details/format.cc(453,41) :  note: previous definition is here
1>  int fmt::internal::CharTraits<wchar_t>::format_float(
1>                                          ^
1>spdlog\details/format.cc(467,41): error : redefinition of 'DIGITS'
1>  const char fmt::internal::BasicData<T>::DIGITS[] =
1>                                          ^
1>  spdlog\details/format.cc(467,41) :  note: previous definition is here
1>  const char fmt::internal::BasicData<T>::DIGITS[] =
1>                                          ^
1>CLANGCOMPILE : fatal error : too many errors emitted, stopping now [-ferror-limit=]
1>  4 warnings and 20 errors generated.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

@vitaut
Copy link

vitaut commented Mar 29, 2016

The pragma issue have been fixed in fmtlib/fmt#256 but spdlog needs to update its copy of cppformat.

Not sure what redefinition errors are about, maybe format.cc is included multiple times somehow?

@LukeMauldin
Copy link
Author

I pulled the latest format.h and format.cc from cppformat and replaced the ones in the spdlog master and in Visual Studio I set format.cc to not be included in the build. After doing those two steps, spdlog builds correctly with Visual Studio 2015 Clang. Can I recommend that spdlog updates its bundled copy of the cppformat library and adds a note to the README to set the format.cc file to not be included in the Visual Studio build?

@gabime
Copy link
Owner

gabime commented Mar 30, 2016

updated spdlog to latest version of cppformat

@gabime gabime closed this as completed Mar 30, 2016
bachittle pushed a commit to bachittle/spdlog that referenced this issue Dec 22, 2022
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

No branches or pull requests

3 participants