diff --git a/src/yycc/env.cpp b/src/yycc/env.cpp index 4a9351f..3f2b282 100644 --- a/src/yycc/env.cpp +++ b/src/yycc/env.cpp @@ -1,40 +1,37 @@ #include "env.hpp" #include "macro/os_detector.hpp" -#include "string/reinterpret.hpp" #include "num/safe_op.hpp" #include "num/safe_cast.hpp" -#include -#include -#include -#include -#include -#include #if defined(YYCC_OS_WINDOWS) +// Windows headers #include "encoding/windows.hpp" #include "windows/winfct.hpp" +#include // For safely free gotten environment variable and commandline argument. +#include // Used by std::unique_ptr to get underlying pointer type. #include "windows/import_guard_head.hpp" #include #include -#include // For getting environment variables and commandline argument. -#include // For getting commandline argument. +#include // For getting environment variables and commandline argument. +#include // For getting commandline argument. #include "windows/import_guard_tail.hpp" -#elif defined(YYCC_OS_LINUX) -#include -#include -#include // For reading commandline argument. -#include -#include // For reading symlink target. +#else +// POSIX headers +#include "string/reinterpret.hpp" +#include // For POSIX environment variable operations. +#include // For POSIX errno. +#include // For re-throw unexpected POSIX errno as STL exception. +#if defined(YYCC_OS_LINUX) +// Linux-only headers +#include // For reading commandline argument. #elif defined(YYCC_OS_MACOS) -#include -#include -#include -#include -#include // For getting current exe path. -#include // For getting commandline argument. +// macOS-only headers +#include // For getting current exe path. +#include // For getting commandline argument. #else #error "Not supported OS" #endif +#endif #define SAFECAST ::yycc::num::safe_cast #define SAFEOP ::yycc::num::safe_op @@ -160,6 +157,7 @@ namespace yycc::env { } #if defined(YYCC_OS_WINDOWS) + class EnvironmentStringsDeleter { public: EnvironmentStringsDeleter() {} @@ -170,6 +168,11 @@ namespace yycc::env { } }; using SmartEnvironmentStrings = std::unique_ptr, EnvironmentStringsDeleter>; + +#else + + extern char** environ; + #endif VarResult> get_vars() {