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

Compile Error VS2019 #1140

Closed
urusaiurusai opened this issue May 5, 2019 · 4 comments
Closed

Compile Error VS2019 #1140

urusaiurusai opened this issue May 5, 2019 · 4 comments

Comments

@urusaiurusai
Copy link

urusaiurusai commented May 5, 2019

  • Error C2993 'fmt::v5::internal::value': illegal type for non-type template parameter '_Test' F:\project\fmt\include\fmt\core.h 904

  • Error C2039 'type': is not a member of 'std' F:\project\fmt\include\fmt\core.h 903

I just #include <fmt/format.h> and do nothing. everything works fine when building the source.

@vitaut
Copy link
Contributor

vitaut commented May 5, 2019

The error looks weird because there is no template parameter _Test anywhere in the library. Perhaps you are seeing some macro conflict from elsewhere.

@vitaut
Copy link
Contributor

vitaut commented May 5, 2019

Also I couldn't repro this on godbolt: https://godbolt.org/z/jHsYkN

@urusaiurusai
Copy link
Author

The errors disapeared if directly append these source code format.h, core.h, format-inl.h and format.cc to a helloworld project instead of using the compiled library fmtd.lib and #include <fmt/format.h>.

There must be something wrong but i can't figure it out. Anyway, I am happy to see it works now.

Thanks.

@mocabe
Copy link
Contributor

mocabe commented May 8, 2019

I experienced same issue with msvc19.21 (VS2019 16.1.0 Preview 3.0).
#include <fmt/format.h> causes this problem.
It seems that MSVC cannot parse (or process) following line correctly.

template <typename C, typename S, FMT_ENABLE_IF(internal::is_string<S>::value)>

Template parameter _Test is probably a parameters of std::enable_if in microsoft STL.

// STRUCT TEMPLATE enable_if
template <bool _Test, class _Ty = void>
struct enable_if {}; // no member "type" when !_Test

The problem is typename internal::is_string<S>::value being processed into fmt::v5::internal::value for some reason. poor is_string<S> 😿

Adding additional parentheses around condition parameter fixed the problem for me.
i.e. change

#define FMT_ENABLE_IF(...) typename std::enable_if<__VA_ARGS__, int>::type = 0

to

#define FMT_ENABLE_IF(...) typename std::enable_if<(__VA_ARGS__), int>::type = 0

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