Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is support of Annex K in C11 required for a conforming implementation?

While answering a question that made use of some functions (sscanf_s and sprintf_s) that I thought were not standard C, Daniel Fischer brought to my attention that the functions in question were defined in Annex K.

I understand generally that normative means it helps define the standard. But, an annex to the C Standard has traditionally been treated as informative only. Annex K is labeled as normative in the C11 Standard. It defines "safe" functions.

Does this mean a compiler that doesn't provided these functions does not conform to the C11 Standard?

I only have the draft C11 Standard available to me, but it states that Annex K is normative, but the library section of the standard makes no mention of the functions discussed in Annex K. A note in the definition of runtime-constraint seems to imply Annex K defines an extension.

Does a normative Annex only define an optional extension?

like image 726
jxh Avatar asked May 22 '13 19:05

jxh


People also ask

What is C11 and C99?

C11 (formerly C1X) is an informal name for ISO/IEC 9899:2011, a past standard for the C programming language. It replaced C99 (standard ISO/IEC 9899:1999) and has been superseded by C17 (standard ISO/IEC 9899:2018).


2 Answers

Annex K is optional; it says so itself.

See K.2 paragraph 2:

An implementation that defines __STDC_LIB_EXT1__ shall conform to the specifications in this annex.

with a footnote:

Implementations that do not define __STDC_LIB_EXT1__ are not required to conform to these specifications.

And paragraph 3 says:

Subclause K.3 should be read as if it were merged into the parallel structure of named subclauses of clause 7.

which is why it's not necessary to mention it in the library section, clause 7 (or at least the authors of the standard didn't feel it was necessary).

An implementation that defines __STDC_LIB_EXT1__ must define it as 201112L; both N1570 and the released C11 standard got this wrong, but it was fixed in a Technical Corrigendum.

like image 95
Keith Thompson Avatar answered Sep 23 '22 09:09

Keith Thompson


It's "normative" in the sense that an implementation claiming to support Annex K must meet the requirements therein. It's not mandatory.

like image 34
R.. GitHub STOP HELPING ICE Avatar answered Sep 25 '22 09:09

R.. GitHub STOP HELPING ICE