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

Doesn't compile on Windows #2623

Open
kdschlosser opened this issue Jan 8, 2022 · 0 comments
Open

Doesn't compile on Windows #2623

kdschlosser opened this issue Jan 8, 2022 · 0 comments

Comments

@kdschlosser
Copy link
Contributor

First error is

openzwave\cpp\src\command_classes\Supervision.cpp(56): error C7555: use of designated initializers requires at least '/std:c++20'

startig at line 55 in Supervision.cpp you have the following code.

m_sessions.push_back({
	.session_id = m_last_session_id, 
	.command_class_id = _command_class_id,
	.index = _index
});

I am not that proficient in C code bit I am guessing that the use of = in the initialize requires c++20.

So I add /std:c++20 to the command line arguments for cl.exe and then I get the next error.

openzwave\cpp\src\Utils.cpp(170): error C2440: 'static_cast': cannot convert from '_Ostr' to 'std::ostringstream &'

and starting at line 167 in Utils .cpp you have the following code

#if __cplusplus==201103L || __APPLE__
			return to_string(x);
#else
			return static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str();
#endif

I do want to mention that when I do not set the compiler flag to c++20 cl.exe defaults to c++14 and Utils.cpp compiles just fine

changing the code in Utils.cpp to read

#if __cplusplus==201103L || __cplusplus>=202002L || __APPLE__
			return to_string(x);
#else
			return static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str();
#endif

and setting the /std:c++20 compiler flag and also /Zc:__cplusplus solves the problem.

The /Zc:__cplusplus flag instructs cl.exe to set the correct standard version to the __cplusplus macro. If that flag does not get used the __cplusplus macro will default to 199711L (c++11). kind of dumb that it works his way but it is Microsoft that made it.

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

1 participant