Writing cross-platform C++ Code (Windows, Linux and Mac OSX)

instead of repeating yourself and writing the same #ifdef …. lines again, again, and again, you’re maybe better of declaring the probe() method in a header, and providing three different source files, one for each platform. This also has the benefit that if you add a platform you do not have to modify all of your existing sources, but just add new files. Use your build system to select the appropriate source file.

Example structure:

include/probe.h
src/arch/win32/probe.cpp
src/arch/linux/probe.cpp
src/arch/mac/probe.cpp

The warning is because probe() doesn’t return a value. In other words, none of the three #ifdefs matches.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)