Platform Layer

Platform support, POSIX-only subsystems, platform guards, and portability rules.

Platform Support Overview

PlatformStatusNotes
LinuxFullPrimary development platform. All tests pass.
macOSFullPOSIX-compatible. Same as Linux.
WindowsPartialCMake links ws2_32. POSIX-only subsystems need Win32 platform guards (known gaps).
AndroidPartialStoragePaths uses SDL3 when available. SDL3 must be provided by the parent project (CNA).
EmscriptenPartialCompiles cleanly. Some features throw PlatformNotSupportedException at runtime.

POSIX-Only Subsystems

These subsystems currently use POSIX-specific APIs and are documented as known bugs, not completed features:

SubsystemPOSIX API UsedStatus
System::Net::Sockets<sys/socket.h>, <unistd.h>POSIX-only
System::IO::RandomAccesspread, pwrite, fsyncDone (has Win32 fallback)
System::AppDomain / AppContext/proc/self/exeLinux-only
System::TimeZoneInfolocaltime_r, /usr/share/zoneinfoPOSIX-only

Platform Guard Rules

These rules are enforced project-wide (see CLAUDE.md):

Example Guard Pattern

// In a .cpp file — platform-specific implementation
#ifdef _WIN32
    #include <windows.h>
    // Win32 implementation
#elif defined(__EMSCRIPTEN__)
    throw System::PlatformNotSupportedException("Not available on Emscripten.");
#else
    #include <unistd.h>
    // POSIX implementation
#endif

Windows-Specific

CMake automatically links ws2_32 on Windows for socket support:

if(WIN32)
    target_link_libraries(SHARP_RUNTIME PRIVATE ws2_32)
endif()

Android-Specific

On Android, SharpRuntime::Storage::StoragePaths uses SDL3 APIs to determine storage paths:

SDL3 headers and library must be available via the parent project before add_subdirectory(sharp-runtime) is called.

Emscripten-Specific

Emscripten (WebAssembly) support requires:

StoragePaths

include/SharpRuntime/Storage/StoragePaths.hpp | src/SharpRuntime/Storage/StoragePaths.cpp

Provides platform-aware isolated storage paths:

std::filesystem::path root = SharpRuntime::Storage::StoragePaths::GetIsolatedStorageRoot();

Implementation varies by platform: uses SDL_GetPrefPath on Android, appropriate paths on other platforms.

Network Sockets

include/System/Net/Sockets/

Status: POSIX-only

ClassHeader
TcpClientSystem/Net/Sockets/TcpClient.hpp
UdpClientSystem/Net/Sockets/UdpClient.hpp
NetworkStreamSystem/Net/Sockets/NetworkStream.hpp

These use <sys/socket.h> and related POSIX headers. Windows and Emscripten support is incomplete.