pmor
pmor

Reputation: 6276

Does name of stdatomic.h contradict with (potential) restriction of the mapping to eight significant characters before the period?

ISO/IEC 9899:2011 (E):

6.10.2.5

The implementation may ignore distinctions of alphabetical case and restrict the mapping to eight significant characters before the period.

Since stdatomic.h has 9 characters before the period, does it make a contradiction with the (potential) restriction above? I.e. that some implementations will not distinguish between stdatomic.h and (for example) stdatomix.h when using them as argument for #include directive?

Extra question: why stdatomic.h and not atomic.h?

Upvotes: 4

Views: 189

Answers (2)

klutt
klutt

Reputation: 31377

If you're using #include <stdatomic.h> then the library header shall be included. But it is free to do the same (or not) with #include <stdatomi.h> or #include <stdatomix.h>

However #include <stdatom.h> shall be treated as a different file. But on the other hand, there's nothing that explicitly forbids an implementation to have a file stdatom.h which only content is #include <stdatomic.h>. Not that any implementation would do it, but it is allowed.

There's no real contradiction here. Just a funny consequence.

Upvotes: 3

John Bollinger
John Bollinger

Reputation: 180201

The implementation may ignore distinctions of alphabetical case and restrict the mapping to eight significant characters before the period.

Since stdatomic.h has 9 characters before the period, does it make a contradiction with the (potential) restriction above?

No, because although it uses the word "restrict", it's not a restriction on the language or on implementations. It's a freedom granted to implementations.

I.e. that some implementations will not distinguish between stdatomic.h and (for example) stdatomix.h when using them as argument for #include directive?

That an implementation did not distinguish between those two as include file names would not make it fail to conform in any way. The standard specifies particular significance for include directives of the form

#include <stdatomic.h>

. As long as the implementation recognizes that directive and gives it the required significance, it is of no consequence with respect to the standard whether

#include <stdatomix.h>

is given the same significance.

Extra question: why stdatomic.h and not atomic.h?

It is a common convention, albeit not a universally observed one, to prefix the names of standard library headers with "std". Other examples include stdalign.h, stdarg.h, stdbool.h, stddef.h, stdint.h, stdio.h, stdlib.h and stdnoreturn.h. I am uncertain about the committee's policy on this, but certainly one of the effects is to reduce the likelihood that the name of a new header added to the standard library collides those of headers used by existing projects.

Upvotes: 1

Related Questions