solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
include
env.h
Go to the documentation of this file.
1
6
#ifndef ENV_H
7
#define ENV_H
8
9
#ifdef __cplusplus
10
extern
"C"
{
11
#endif
12
13
#include <stdlib.h>
// for getenv, setenv, unsetenv, secure_getenv (Linux)
14
31
// Platform detection
32
#if defined(__linux__)
33
#define GETENV(name) secure_getenv(name)
34
#else
35
#define GETENV(name) getenv(name)
36
#endif
37
38
// SETENV macro - cross-platform environment variable setting
39
#if defined(_WIN32) || defined(_WIN64)
40
#include <stdlib.h>
// for _putenv_s
48
#define SETENV(name, value, overwrite) _putenv_s(name, value)
49
56
#define UNSETENV(name) _putenv_s(name, "")
57
#else
58
// POSIX systems (Linux, macOS, BSD, etc.)
66
#define SETENV(name, value, overwrite) setenv(name, value, overwrite)
67
73
#define UNSETENV(name) unsetenv(name)
74
#endif
75
76
#ifdef __cplusplus
77
}
78
#endif
79
80
#endif
// ENV_H
Generated by
1.9.8