Is C ++ source code portable on linux when it successfully compiles in Visual Studio 2010

I would like to use Visual Studio 2010 to create a C++ application that will eventually run on Linux

Are there any compatibility / version issues that I should be aware of? Which compiler should be used on Windows and Linux ?

+4
source share
3 answers

The compiler is unimportant if you use standard C ++ and do not use extensions for a specific platform. If you need system tools (network, file system ...), try using an abstraction layer, such as boost .

+6
source

There are many problems that you need to know about, unfortunately. The most important thing, as other people have noted, is that you use only standard C ++ plus any libraries that are portable to all the platforms you are targeting. But there are many other things to bite you, for example. different versions of strings (Windows uses \ r \ n, Unix variants usually use \ n), different data types, etc. In general, when you try to keep things portable, you also need to know about things like endianness, byte ordering, how various file systems work, etc.

In fact, the most important thing is to get acquainted with all the systems that you are aiming at. Do not write it on one system, and then expect that you can compile it without pain on another. Instead, compile it on all relevant systems from day one and make sure that it continues to work on all of them all the time. I recommend exploring a cross-platform build system such as CMake ( http://www.cmake.org ) - this will save you the pain in my experience. You don’t want makefiles running on multiple platforms all the time if you can help.

+4
source

Use standard C ++. Try not to use compiler-specific functions like __int64 or platform-specific external libraries, and you should be fine.

+3
source

All Articles