Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Environment.ixx File Reference

Reading an environment variable, once, safely. More...

#include <cstdlib>
#include <optional>
#include <string>

Namespaces

namespace  Mila
 Mila main API namespace.

Functions

std::optional< std::string > Mila::Distribution::readEnvironmentVariable (const char *name)
 The value of an environment variable, or nothing.

Detailed Description

Reading an environment variable, once, safely.

The only place in the library that calls std::getenv, and therefore the only file needing an exemption from the MSVC CRT's deprecation of it. Callers receive an owned string or nothing, so the borrowed pointer whose lifetime the warning is about never escapes this file.

Function Documentation

◆ readEnvironmentVariable()

std::optional< std::string > Mila::Distribution::readEnvironmentVariable ( const char * name)
export

The value of an environment variable, or nothing.

An empty value reads as absent. Every caller here is choosing a path or a credential from a first-match-wins list, and an exported-but-empty variable means "not configured" in that setting rather than "configured to the empty string".