Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Platform dependencies may be introduced to improve performance on a particular platform. This can be a dangerous practice, particularly if these dependencies are not appropriately documented during development and addressed during porting. Platform dependencies that have no performance or other benefits should consequently be avoided as the y they may introduce errors during porting.

The C99 standard identifies two different kinds of non-portable behavior, implementation-defined and unspecified.

C99 Section 3.4.1 defines implementation-defined behavior as:

unspecified behavior where each implementation documents how the choice is made

An example of implementation-defined behavior is the propagation of the high-order bit when a signed integer is shifted right.

C99 Section 3.4.4 defines unspecified behavior as:

use of an unspecified value, or other behavior where this International Standard provides two or more possibilities and imposes no further requirements on which is chosen in any instance

An example of unspecified behavior is the order in which the arguments to a function are evaluated.

Appendix J.1, "Unspecified behavior" provides a list of unspecified behaviors in C99, and Appendix J.3, "Implementation-defined behavior" provides a list of implementation-defined behaviors in C99.

Most legitimate platform dependencies can and should be isolated in separate modules that use portable interfaces but platform-specific implementations.

...