Search code examples
c++macosclangdarwin

secure_getenv() on macOS


Why does secure_getenv() only works on my GNU/Linux system but not on macOS? Compiling it there results in the following error:

main.cpp:31:26: error: use of undeclared identifier 'secure_getenv'
    char* env_custom_path = secure_getenv("MY_ENV_VAR");

Why is that the case?


Solution

  • From this manual page

    The GNU-specific secure_getenv() function

    [Emphasis mine]

    It's not a standard function, so it's simply not available on macOS.