Constraints

Download c eBook

Remarks

Constraints are a term used in all of the existing C specifications (recently ISO-IEC 9899-2011). They are one of the three parts of the language described in clause 6 of the standard (along side syntax and semantics).

ISO-IEC 9899-2011 defines a constraint as a:

restriction, either syntactic or semantic, by which the exposition of language elements is to be interpreted

(Please also note, in terms of the C standard, a "runtime-constraint" is not a kind of constraint and has extensively different rules.)

In other words a constraint describes a rule of the language which would make an otherwise syntactically valid program illegal. In this respect constraints are somewhat like undefined behavior, any program which does not follow them is not defined in terms of the C language.

Constraints on the other hand have a very significant difference from Undefined Behaviors. Namely an implementation is required to provide a diagnostic message during the translation phase (part of compilation) if a constraint is breached, this message may be a warning or may halt the compilation.

Related Examples

Stats

52 Contributors: 3
Thursday, October 13, 2016
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook