How to setup visual studio for cross platform c++ development

前端 未结 4 488
星月不相逢
星月不相逢 2020-12-25 13:42

After some time mainly .net development, i need to work in c++ in a cross platform manner.

I don\'t want to give up visual studio, so my hope was that it is possible

4条回答
  •  清酒与你
    2020-12-25 14:36

    First of all, select a non-managed C++ project (to avoid the .net stuff).

    After that, turn up the warning level (/W3 should do), and be very careful what you do/write. IMHO, GCC is better at keeping you straight with the standard (-Wall -Wextra -pedantic -std=c++11), but you specify MSVC.

    As Noah said, you'll need build system that is in itself cross-platform, like CMake (there are others, please don't forget that).

    Remember to use platform/architecture/compiler independent types, like std::size_t, std::(u)intptr_t etc. instead of plain int, long, unsigned: these are a recipe for disaster and the Windows API throws these around way too much.

    See here, but only/especially points 1, 2, 5, and 8 (and 9, but generalize that to svn, git, mercurial).

提交回复
热议问题