Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: ENV30 compliance

...

The following noncompliant code behaves differently when compiled and run on Linux and Microsoft Windows platforms.

Code Block
bgColor#ffcccc
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
bgColor#ccccff

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);

...