Environment Variables in Cilk
Environment variables are a universal mechanism for conveying configuration information to Unix programs. Let’s look at how to set, get, and list environment variables in Cilk.
Running the program shows that we pick up the value for FOO
that we set in the program, but that BAR
is empty.
The list of keys in the environment will depend on your particular machine.
If we set BAR
in the environment first, the running program picks that value up.
Note that Cilk, being an extension of C++, uses C++ standard library functions for environment variable operations. The setenv
and getenv
functions are part of the C standard library, which is accessible in C++. The environ
variable is also a C feature that’s available in C++.
Also, Cilk doesn’t provide any specific features for handling environment variables beyond what C++ offers. The parallel programming features of Cilk are not directly applicable to this example, but could be used if you needed to process environment variables in parallel.