...
The following noncompliant code behaves differently when compiled and run on Linux and Microsoft Windows platforms.
Code Block | ||
---|---|---|
| ||
char *temp; if (putenv("TEST_ENV=foo") != 0) { /* Handle Error */ } if (putenv("Test_ENV=bar") != 0) { /* Handle Error */ } const char *temp = getenv("TEST_ENV"); if (temp == NULL) { /* Handle Error */ } printf("%s\n", temp); |
...
Portable code should use environment variables that differ by more than capitalization.
Code Block | ||
---|---|---|
| ||
char *temp; if (putenv("TEST_ENV=foo") != 0) { /* Handle Error */ } if (putenv("OTHER_ENV=bar") != 0) { /* Handle Error */ } const char *temp = getenv("TEST_ENV"); if (temp == NULL) { /* Handle Error */ } printf("%s\n", temp); |
...