C alternative tokens
| C standard library |
|---|
| General topics |
| Miscellaneous headers |
C alternative tokens refer to a set of alternative spellings of common operators in the C programming language. They are implemented as a group of macro constants in the C standard library in the iso646.h header. The tokens were created by Bjarne Stroustrup for the pre-standard C++ language[1] and were added to the C standard in a 1995 amendment to the C90 standard via library to avoid the breakage of existing code.
The alternative tokens allow programmers to use C language bitwise and logical operators which could otherwise be hard to type on some international and non-QWERTY keyboards. The name of the header file they are implemented in refers to the ISO/IEC 646 standard, a 7-bit character set with a number of regional variations, some of which have accented characters in place of the punctuation marks used by C operators.
The macros
The iso646.h header defines the following 11 macros as stated below:[2]
| Macro | Defined as |
|---|---|
and |
&&
|
and_eq |
&=
|
bitand |
&
|
bitor |
|
|
compl |
~
|
not |
!
|
not_eq |
!=
|
or |
||
|
or_eq |
|=
|
xor |
^
|
xor_eq |
^=
|
C++
The above-mentioned identifiers are operator keywords in the ISO C++ programming language and do not require the inclusion of a header file.[3] For consistency, the C++98 standard provided both <iso646.h> and a corresponding <ciso646>. However they both had no effect, being empty.[4] Some compilers, such as Microsoft Visual C++ have, at least in the past, required the header to be included in order to use these identifiers unless a compiler flag is set.[5] The header <ciso646> was deprecated in C++17, and removed in C++20,[6] while <iso646.h> was retained for compatibility with C.[7]
See also
References
- ↑ "CppCon 2017: Panel “Grill the Committee”". https://www.youtube.com/watch?v=JYG5LFHkUuE&t=4582.
- ↑ "Rationale for International Standard - Programming Languages - C". April 2003. http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf.
- ↑ Design and Evolution of C++ (1st ed.). Addison-Wesley Publishing Company. 1994-03-29. ISBN 0-201-54330-3.
- ↑ Lischner, Ray (2003). C++ in a Nutshell. O'Reilly Media. p. 212. ISBN 0-596-00298-X.
- ↑ "Logical AND Operator:
&&". 2021-11-23. https://docs.microsoft.com/en-us/cpp/cpp/logical-and-operator-amp-amp?view=msvc-170#operator-keyword-for-. - ↑ Whitney, Tyler (2021-12-07). "<ciso646>". https://learn.microsoft.com/en-us/cpp/standard-library/ciso646.
- ↑ Köppe, Thomas (2021-06-11). "Clarifying the status of the “C headers”". C++ Standards Committee Papers (ISO/IEC JTC1 SC22 WG21). https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2340r1.html.
External links
- : alternative spellings – Base Definitions Reference, The Single UNIX Specification, Issue 7 from The Open Group

