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

MSVC compile errors with /Zc:__cplusplus #61

Closed
GIGte opened this issue Aug 21, 2019 · 12 comments
Closed

MSVC compile errors with /Zc:__cplusplus #61

GIGte opened this issue Aug 21, 2019 · 12 comments

Comments

@GIGte
Copy link
Contributor

GIGte commented Aug 21, 2019

I'm using Visual Studio 2019. When I add option /Zc:__cplusplus (fixes __cplusplus macro value) it refuses to compile. I get strange errors like
yas\include\yas\types\std\pair.hpp(63,1): error C2975: '_Val': invalid template argument for 'std::integral_constant', expected compile-time constant expression

I did a quick test with file examples/one_memfn/main.cpp

This compiles:
cl main.cpp /I"../../include" /EHsc /std:c++17 /permissive-

And this does not:
cl main.cpp /I"../../include" /EHsc /std:c++17 /permissive- /Zc:__cplusplus

This probably has something to do with fnv1a function in include\yas\detail\tools\fnv1a.hpp . If you switch to the code for __cplusplus < 201402L yas compiles just fine.

@niXman
Copy link
Owner

niXman commented Aug 21, 2019

please provide the link to the docs for /Zc:__cplusplus because I can't google it

@GIGte
Copy link
Contributor Author

GIGte commented Aug 21, 2019

@niXman
Copy link
Owner

niXman commented Aug 22, 2019

provide please the preprocessed code of examples/one_memfn/main.cpp source with enabled /Zc:__cplusplus

@GIGte
Copy link
Contributor Author

GIGte commented Aug 23, 2019

Full sample one_memfn.zip

I changed YAS_THROW_EXCEPTION to __YAS_THROW_EXCEPTION because it doesn't work otherwise :)

@niXman
Copy link
Owner

niXman commented Aug 23, 2019

hmm... there is no preprocessed code in the archive...

@niXman
Copy link
Owner

niXman commented Aug 23, 2019

I changed YAS_THROW_EXCEPTION to __YAS_THROW_EXCEPTION because it doesn't work otherwise :)

did this solve your problem?

@GIGte
Copy link
Contributor Author

GIGte commented Aug 23, 2019

Ah, I just didn't understand. This preprocessed code main.zip ?

did this solve your problem?

No, it didn't. This seems like a bug in the examples. The macro without the underscores cannot be found.

@niXman
Copy link
Owner

niXman commented Aug 24, 2019

This preprocessed code main.zip ?

yes.

I think was fixed in master, please check and let me know the result.

@GIGte
Copy link
Contributor Author

GIGte commented Aug 24, 2019

Still errors. Now
error C2664: 'uint32_t yas::detail::fnv1a(std::nullptr_t)': cannot convert argument 1 from 'char [1024]' to 'std::nullptr_t'

The function fnv1a(const CharT ...) gets skipped. I thought about #if __cplusplus >= 201402L && !defined(_MSC_VER). This does not look like the best solution but after I put this line it worked.

@niXman
Copy link
Owner

niXman commented Aug 25, 2019

my bad, sorry.
fixed in master.
check now please.

@GIGte
Copy link
Contributor Author

GIGte commented Aug 25, 2019

It works.

@niXman
Copy link
Owner

niXman commented Aug 25, 2019

great, please close.

@GIGte GIGte closed this as completed Aug 25, 2019
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

2 participants