Skip to main content

IAR Embedded Workbench for RL78 5.20

getenv

In this section:
Source file
rl78\src\lib\runtime\getenv.c
rl78\src\lib\runtime\environ.c
Declared in

Stdlib.h and LowLevelIOInterface.h

C-SPY debug action

Accesses the host environment.

Default implementation

The getenv function in the library searches the string pointed to by the global variable __environ, for the key that was passed as argument. If the key is found, the value of it is returned, otherwise 0 (zero) is returned. By default, the string is empty.

To create or edit keys in the string, you must create a sequence of null-terminated strings where each string has the format:

key=value\0

End the string with an extra null character (if you use a C string, this is added automatically). Assign the created sequence of strings to the __environ variable.

For example:

const char MyEnv[] = "Key=Value\0Key2=Value2\0";
__environ = MyEnv;

If you need a more sophisticated environment variable handling, you should implement your own getenv, and possibly putenv function.

Note

The putenv function is not required by the standard, and the library does not provide an implementation of it.

See also

Briefly about retargeting.