In 1990 P.J. Plauger wrote (emphasis added):
Standard C offers you an additional level of security, however. It is a level offered in no other language standard that I know. It promises that if you avoid certain sets of names, you will experience no collisions. Thus, Standard C makes it that much easier to write highly portable applications.
In C11 keyword _Alignas
(for example) was introduced with the accompanying macro alignas
defined in <stdalign.h>
. Here we see that the keyword is _Alignas
, not alignas
(since in pre-C11 alignas
is not reserved). Hence, there is no collision with possible user-defined alignas
.
However, in C2x the alignas
is a keyword and <stdalign.h>
provides no content (and C2x says nothing about __alignas_is_defined
macro -- defect?). It means that in C2x any pre-C2x code containing user-defined alignas
will cause semantics violation and, hence, breaks backward compatibility.
Questions:
alignas
(for example) to be a keyword rather than a macro?The proposal for these change (available at https://open-std.org/JTC1/SC22/WG14/www/docs/n2934.pdf) argues that the naming strategy in regards to new keywords has already been inconsistent with previous standard versions:
some were integrated using non-reserved names (
const
,inline
) others were integrated in an underscore-capitalized form. For some of them, the use of the lower-case form then is ensured via a set of library header files.
Further using the same keyword naming as C++ (for compatibility purposes) is also mentioned in the proposal, since some keywords originated in that language and were later added to C.