September 2018
Intermediate to advanced
606 pages
14h 32m
English
For this example, we will modify the hello-world.cpp example code from Chapter 1, From a Simple Executable to Libraries, Recipe 1, Compiling a single source file into an executable:
#include <cstdlib>#include <iostream>#include <string>std::string say_hello() {#ifdef IS_WINDOWS return std::string("Hello from Windows!");#elif IS_LINUX return std::string("Hello from Linux!");#elif IS_MACOS return std::string("Hello from macOS!");#else return std::string("Hello from an unknown system!");#endif}int main() { std::cout << say_hello() << std::endl; return EXIT_SUCCESS;}
Read now
Unlock full access