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

Cannot build on Windows with Visual Studio #3042

Closed
degloff opened this issue Mar 16, 2024 · 1 comment
Closed

Cannot build on Windows with Visual Studio #3042

degloff opened this issue Mar 16, 2024 · 1 comment

Comments

@degloff
Copy link

degloff commented Mar 16, 2024

I wonder what is wrong here

// without this defined it does not build 
#define _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS

#include "spdlog/spdlog.h"

int main()
{
    std::string a = "abc";
    std::string b = "123";
    
    spdlog::debug("a={}, b={}", a, b);

    SPDLOG_DEBUG("Some debug message");
}

If I remove #define _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS I get the following error

1>test_spdlog.cpp
1>xxx\spdlog\fmt\bundled\format.h(490,51): error C4996: 'stdext::checked_array_iterator<_Ty*>': warning STL4043: stdext::checked_array_iterator, stdext::unchecked_array_iterator, and related factory functions are non-Standard extensions and will be removed in the future. std::span (since C++20) and gsl::span can be used instead. You can define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING or _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS to suppress this warning.
1>(compiling source file 'test_spdlog.cpp')
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\iterator(1470,1):
1>see declaration of 'stdext::checked_array_iterator'
1>xxx\spdlog\fmt\bundled\format.h(493,3): error C4996: 'stdext::checked_array_iterator<T *>::checked_array_iterator': warning STL4043: stdext::checked_array_iterator, stdext::unchecked_array_iterator, and related factory functions are non-Standard extensions and will be removed in the future. std::span (since C++20) and gsl::span can be used instead. You can define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING or _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS to suppress this warning.
1>xxx\spdlog\fmt\bundled\format.h(493,3): error C4996:         with
1>xxx\spdlog\fmt\bundled\format.h(493,3): error C4996:         [
1>xxx\spdlog\fmt\bundled\format.h(493,3): error C4996:             T=fmt::v9::detail::bigint::bigit
1>xxx\spdlog\fmt\bundled\format.h(493,3): error C4996:         ]
1>(compiling source file 'test_spdlog.cpp')
1>xxx\spdlog\fmt\bundled\format.h(493,3):
1>the template instantiation context (the oldest one first) is
1>	xxx\spdlog\fmt\bundled\format.h(2807,34):
1>	see reference to function template instantiation 'stdext::checked_array_iterator<T *> fmt::v9::detail::make_checked<T>(T *,size_t)' being compiled
1>        with
1>        [
1>            T=fmt::v9::detail::bigint::bigit
1>        ]

I tried with all the language version C++14 to C++20. Do I use spdlog in a wrong way? I use the header only version which I cloned directly from Github.

@tt4g
Copy link
Contributor

tt4g commented Mar 16, 2024

Duplicate #2987 and already fixed fmtlib/fmt#3540.
If you define _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS, you should also define CMake variable SPDLOG_FMT_EXTERNAL and use external fmt.

@gabime gabime closed this as completed Mar 28, 2024
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