如何为跨平台c ++开发设置visual studio

Toa*_*oad 23 c++ unix windows cross-platform visual-studio

经过一段时间后主要是.net开发,我需要以跨平台的方式在c ++中工作.

我不想放弃visual studio,所以我希望可以使用visual studio和windows target作为testbuild,然后每隔一段时间通过vm测试linux或mac上的代码.

有没有人有如何最好地设置它的经验?

我特别好奇你如何确保像项目文件这样的东西与*nix平台上可能需要的make文件保持同步.

rub*_*nvb 15

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).

请记住,使用平台/建筑/编译器独立的类型,如std::size_t,std::(u)intptr_t等来代替普通的int,long,unsigned:这些都是一个灾难和Windows API抛出这些周围太多.

请参阅此处,但仅限于/特别是第1,2,5和8点(和9,但将其概括为svn,git,mercurial).


Edw*_*nge 5

我特别好奇您如何确保项目文件等内容与 *nix 平台上可能需要的 make 文件保持同步。

由于 MS 决定从 VS 中删除对 makefile 的支持,因此您不需要。您使用其他可以生成 VS 项目文件的东西,并确保正确设置。像 CMake 的东西。