C ++ platform code

We are going to start a new project in our small team:

  • This is the library that will be used by our other projects (on Linux and Windows).
  • It does not logically depend on the platform (it does not use any system calls or anything like that).
  • It must be compiled on different platforms (including Windows and Linux, at least).

Unfortunately, our developers have never written a single code on any platform other than Windows! So I have to give them a “code like this or ”, not a code like this list , so the code will remain cross-platform.

any guidance?

+5
source share
7

GCC . , , , , ++ . , GNU make, , .

- , , :

#include <windows.h>
#include <unistd.h>
#include <sys/almost_anything.h>

.

+10

, , . , . , -.

( , , , ), , . , 32- MCVC 64- gcc unix. , .

, , , , "" . , , , , , - .

, ,

  • , ints - 32
  • , char
  • , ASCII
  • .
  • . , , .
  • , - . unix, , , z-series VMS, -.
+7

: , ( ) .

, Boost (, Linux/GCC Windows/MSVC). , .h, , .

, , , , .

+6

, Windows API, .

/ Visual Studio, , gcc () , , gcc Linux, Visual Studio .

, - - , , , , , .

+5

, . , VC, gcc, intel, pgi. , . , , . , , .

+2

:

  • static_cast<>, dynamic_cast<> const_cast<> C. reinterpret_cast<>, . ( , .)

  • ++: , MS, (brrr!) MFC CString.

, , (, # 16 , # 18 STL ).

+1

From the Linux development experience among Windows developers, the main problem usually (assuming you really don't use platform-specific code, as you say) is simply case sensitivity in #include names. In addition, you will find that gcc is stricter by default than MSVC, and you may need to pull it up a bit, but they are usually pretty simple.

Of particular note is that the std::map::eraseiterator does not return .

0
source

All Articles