C alternative tokens

Last updated

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.

Contents

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]

MacroDefined 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] [5] 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. [6] [7] The header <ciso646> was deprecated in C++17, and removed in C++20, [8] while <iso646.h> was retained for compatibility with C. [9]

See also

Related Research Articles

ANSI C, ISO C, and Standard C are successive standards for the C programming language published by the American National Standards Institute (ANSI) and ISO/IEC JTC 1/SC 22/WG 14 of the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC). Historically, the names referred specifically to the original and best-supported version of the standard. Software developers writing in C are encouraged to conform to the standards, as doing so helps portability between compilers.

C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, and protocol stacks, but its use in application software has been decreasing. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.

<span class="mw-page-title-main">C++</span> General-purpose programming language

C++ is a high-level, general-purpose programming language created by Danish computer scientist Bjarne Stroustrup. First released in 1985 as an extension of the C programming language, it has since expanded significantly over time; as of 1997, C++ has object-oriented, generic, and functional features, in addition to facilities for low-level memory manipulation for making things like microcomputers or to make operating systems like Linux or Windows. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Embarcadero, Oracle, and IBM.

The C preprocessor is the macro preprocessor for several computer programming languages, such as C, Objective-C, C++, and a variety of Fortran languages. The preprocessor provides inclusion of header files, macro expansions, conditional compilation, and line control.

The C standard library or libc is the standard library for the C programming language, as specified in the ISO C standard. Starting from the original ANSI C standard, it was developed at the same time as the C library POSIX specification, which is a superset of it. Since ANSI C was adopted by the International Organization for Standardization, the C standard library is also called the ISO C library.

In the C++ programming language, the C++ Standard Library is a collection of classes and functions, which are written in the core language and part of the C++ ISO Standard itself.

This is a list of operators in the C and C++ programming languages. All the operators listed exist in C++; the column "Included in C", states whether an operator is also present in C. Note that C does not support operator overloading.

<span class="mw-page-title-main">C99</span> C programming language standard, 1999 revision

C99 is an informal name for ISO/IEC 9899:1999, a past version of the C programming language standard. It extends the previous version (C90) with new features for the language and the standard library, and helps implementations make better use of available computer hardware, such as IEEE 754-1985 floating-point arithmetic, and compiler technology. The C11 version of the C programming language standard, published in 2011, updates C99.

Managed code is computer program code that requires and will execute only under the management of a Common Language Infrastructure (CLI); Virtual Execution System (VES); virtual machine, e.g. .NET, CoreFX, or .NET Framework; Common Language Runtime (CLR); or Mono. The term was coined by Microsoft.

The C and C++ programming languages are closely related but have many significant differences. C++ began as a fork of an early, pre-standardized C, and was designed to be mostly source-and-link compatible with C compilers of the time. Due to this, development tools for the two languages are often integrated into a single product, with the programmer able to specify C or C++ as their source language.

assert.h is a header file in the C standard library. It defines the C preprocessor macro assert and implements runtime assertion in C.

The C++ programming language has support for string handling, mostly implemented in its standard library. The language standard specifies several string types, some inherited from C, some designed to make use of the language's features, such as classes and RAII. The most-used of these is std::string.

In the C++ programming language, placement syntax allows programmers to explicitly specify the memory management of individual objects — i.e. their "placement" in memory. Normally, when an object is created dynamically, an allocation function is invoked in such a way that it will both allocate memory for the object, and initialize the object within the newly allocated memory. The placement syntax allows the programmer to supply additional arguments to the allocation function. A common use is to supply a pointer to a suitable region of storage where the object can be initialized, thus separating memory allocation from object construction.

In C++ computer programming, allocators are a component of the C++ Standard Library. The standard library provides several data structures, such as list and set, commonly referred to as containers. A common trait among these containers is their ability to change size during the execution of the program. To achieve this, some form of dynamic memory allocation is usually required. Allocators handle all the requests for allocation and deallocation of memory for a given container. The C++ Standard Library provides general-purpose allocators that are used by default, however, custom allocators may also be supplied by the programmer.

C11 is an informal name for ISO/IEC 9899:2011, a past standard for the C programming language. It replaced C99 and has been superseded by C17. C11 mainly standardizes features already supported by common contemporary compilers, and includes a detailed memory model to better support multiple threads of execution. Due to delayed availability of conforming C99 implementations, C11 makes certain features optional, to make it easier to comply with the core language standard.

Concepts are an extension to the templates feature provided by the C++ programming language. Concepts are named Boolean predicates on template parameters, evaluated at compile time. A concept may be associated with a template, in which case it serves as a constraint: it limits the set of arguments that are accepted as template parameters.

In the C++ programming language, decltype is a keyword used to query the type of an expression. Introduced in C++11, its primary intended use is in generic programming, where it is often difficult, or even impossible, to express types that depend on template parameters.

The following outline is provided as an overview of and topical guide to C++:

In the C++ programming language, input/output library refers to a family of class templates and supporting functions in the C++ Standard Library that implement stream-based input/output capabilities. It is an object-oriented alternative to C's FILE-based streams from the C standard library.

C++20 is a version of the ISO/IEC 14882 standard for the C++ programming language. C++20 replaced the prior version of the C++ standard, called C++17, and was later replaced by C++23. The standard was technically finalized by WG21 at the meeting in Prague in February 2020, had its final draft version announced in March 2020, was approved on 4 September 2020, and published in December 2020.

References

  1. "CppCon 2017: Panel "Grill the Committee"". YouTube . Archived from the original on 2021-12-12.
  2. "Rationale for International Standard - Programming Languages - C" (PDF). 5.10. April 2003. Archived (PDF) from the original on 2016-06-06. Retrieved 2010-10-17.
  3. Stroustrup, Bjarne (1994-03-29). Design and Evolution of C++ (1st ed.). Addison-Wesley Publishing Company. ISBN   0-201-54330-3.
  4. Lischner, Ray (2003). C++ in a Nutshell. O'Reilly Media. p. 384. ISBN   0-596-00298-X.
  5. Van Weert, Peter; Gregoire, Marc (2019). C++17 Standard Library Quick Reference. Apress. p. 277. ISBN   9781484249239.
  6. Deitel, Paul; Deitel, Harvey M. (2013). C++11 for Programmers. Pearson Education. p. 928. ISBN   9780133439878.
  7. "Logical AND Operator: &&". Microsoft Docs. 2021-11-23. Archived from the original on 2021-12-28. Retrieved 2021-12-27.
  8. Whitney, Tyler (2021-12-07). "<ciso646>". Microsoft Learn.
  9. Köppe, Thomas (2021-06-11). "Clarifying the status of the "C headers"". C++ Standards Committee Papers. ISO/IEC JTC1 SC22 WG21. Archived from the original on 2024-01-11.