Windows and Linux System Libraries
Where Win32 and POSIX genuinely diverge — process creation, threading, dynamic loading, paths, file semantics, sockets — and how to structure a codebase so platform code is isolated rather than scattered across ifdefs.
Overview
Where cross-platform C++ actually breaks
Cross-platform C++ rarely breaks at the language level: MSVC and GCC/Clang implement the same standard, and since C++17 the library covers paths, threads and time reasonably well. What breaks is the layer beneath, the system libraries. Win32 and POSIX were designed from different premises, and where they differ, they differ structurally.
The picture to hold in your head has two routes down from your code. What the standard covers goes through the standard library. Everything else goes through a thin platform layer of your own, which is the only code that knows which operating system it is on.
The rest of this chapter walks the places where the two system libraries part ways, starting with the biggest.
Key concepts
- Win32 API
- POSIX
- CreateProcess vs fork/exec
- HANDLE vs file descriptor
- Export visibility asymmetry
- MAX_PATH and long-path opt-in
- Mandatory share modes
- Winsock initialization
Interview questions
- Windows has no fork(). How do you design a process-spawning abstraction that works on both platforms?
- How does std::thread map onto Windows threads and pthreads, and what leaks through the abstraction?
- A build tool works on Linux and intermittently fails on Windows deleting or replacing output files. Diagnose it.
- Walk through the path and filename differences that break cross-platform code.
- How do you structure a codebase so platform code is isolated rather than ifdef-scattered, and when do you adopt a portability layer?
Sign up free to read the full topic
More DevOps topics
Start free on Cariara · Coding problems · System design studio