RA3Bar-RA3Launcher icon indicating copy to clipboard operation
RA3Bar-RA3Launcher copied to clipboard

Migrate to new c++17 and adapt for msvc

Open runapp opened this issue 4 years ago • 6 comments

runapp avatar Jan 09 '21 21:01 runapp

Adapting to a certain compiler is really a dirty work, especially for an amateur C++ user like me. I just tried to make least change to get it compiled, as well as keeping mingw working. So I'd be very appreciated for any suggestions, from which can I get tips about C++ programming without diving into new C++ standards. 🤣

runapp avatar Jan 10 '21 23:01 runapp

Uh I've tried to declare static constexpr auto allButtons2 = {playGame}; which MSVC complains C2131 ...

runapp avatar Jan 11 '21 01:01 runapp

Uh I've tried to declare static constexpr auto allButtons2 = {playGame}; which MSVC complains C2131 ...

@runapp If MSVC do complain C2131 on constexpr initializer_list, then sure you can change it to const. But for other constexpr auto variables, if they are used inside lambdas, you can declare them as static auto constexpr, so we can avoid unnecessary changes in lambda capture lists.

lanyizi avatar Jan 11 '21 02:01 lanyizi

Hmmm... I've checked all the changed declaration. Seems all of them are initializer_list?

runapp avatar Jan 11 '21 04:01 runapp

Hmmm... I've checked all the changed declaration. Seems all of them are initializer_list?

@runapp I mean those lambda capture lists, you can remove the default capture and restore them to the original code. If MSVC complains that some variables are not captured, then change them from auto constexpr to static auto constexpr.

lanyizi avatar Jan 11 '21 06:01 lanyizi

Can you also update the README.md, since it can now be compiled with MSVC?

lanyizi avatar Jan 12 '21 18:01 lanyizi