Skip to main content

Compatibility and Strandered library of C++

To give compiler vendors greater freedom, the C++ standards committee decided not to dictate the implementation of name manglingexception handling, and other implementation-specific features. The downside of this decision is that object code produced by different compilers is expected to be incompatible. There were, however, attempts to standardize compilers for particular machines or operating systems (for example C++ ABI),[53] though they seem to be largely abandoned now.

With CEdit

For more details on this topic, see Compatibility of C and C++.
C++ is often considered to be a superset of C, but this is not strictly true.[54]Most C code can easily be made to compile correctly in C++, but there are a few differences that cause some valid C code to be invalid or behave differently in C++. For example, C allows implicit conversion from void* to other pointer types, but C++ does not (for type safety reasons). Also, C++ defines many new keywords, such as new and class, which may be used as identifiers (for example, variable names) in a C program.
Some incompatibilities have been removed by the 1999 revision of the C standard (C99), which now supports C++ features such as line comments (//), and declarations mixed with code. On the other hand, C99 introduced a number of new features that C++ did not support, were incompatible or redundant in C++, such as variable-length arrays, native complex-number types (however, the std::complex class in the C++ standard library provides similar functionality, although not code compatible), designated initializers, compound literals, and the restrict keyword.[55] Some of the C99-introduced features were included in the subsequent version of the C++ standard, C++11 (out of those which were not redundant).[56][57][58] However, the C++11 standard introduces new incompatibilities, such as disallowing assignment of a string literal to a character pointer, which remains valid C.
To intermix C and C++ code, any function declaration or definition that is to be called from/used both in C and C++ must be declared with C linkage by placing it within an extern "C" {/*...*/} block. Such a function may not rely on features depending on name mangling (i.e., function overloading).

Standard libraryEdit

Main article: C++ Standard Library
The C++ standard consists of two parts: the core language and the standard library. C++ programmers expect the latter on every major implementation of C++; it includes vectors, lists, maps, algorithms (find, for_each, binary_search, random_shuffle, etc.), sets, queues, stacks, arrays, tuples, input/output facilities (iostream, for reading from and writing to the console and files), smart pointersfor automatic memory management, regular expression support, multi-threading library, atomics support (allowing a variable to be read or written to by at most one thread at a time without any external synchronisation), time utilities (measurement, getting current time, etc.), a system for converting error reporting that doesn't use C++ exceptions into C++ exceptions, a random number generator and a slightly modified version of the C standard library (to make it comply with the C++ type system).
A large part of the C++ library is based on the Standard Template Library (STL). Useful tools provided by the STL include containers as the collections of objects (such as vectors and lists), iterators that provide array-like access to containers, and algorithms that perform operations such as searching and sorting.
Furthermore, (multi)maps (associative arrays) and (multi)sets are provided, all of which export compatible interfaces. Therefore, using templates it is possible to write generic algorithms that work with any container or on any sequence defined by iterators. As in C, the features of the library are accessed by using the #include directive to include a standard header. C++ provides 105 standard headers, of which 27 are deprecated.
The standard incorporates the STL that was originally designed by Alexander Stepanov, who experimented with generic algorithms and containers for many years. When he started with C++, he finally found a language where it was possible to create generic algorithms (e.g., STL sort) that perform even better than, for example, the C standard library qsort, thanks to C++ features like using inlining and compile-time binding instead of function pointers. The standard does not refer to it as "STL", as it is merely a part of the standard library, but the term is still widely used to distinguish it from the rest of the standard library (input/output streams, internationalization, diagnostics, the C library subset, etc.).[52]
Most C++ compilers, and all major ones, provide a standards conforming implementation of the C++ standard library.

source wikipedia

Comments

Popular posts from this blog

QBasic and its history

QBasic Not to be confused with  Quick Basic . QBasic Paradigm Procedural Developer Microsoft First appeared 1991 ; 25 years ago OS MS-DOS ,  Windows 95 ,  Windows 98 ,  Windows Me ,  PC DOS ,  OS/2 , eComStation License Part of the operating system (a variety of  closed-source  licenses) Website www .microsoft .com Influenced by QuickBASIC ,  GW-BASIC Influenced QB64 ,  Small Basic QBasic  ( Microsoft  Quick Beginners All purpose Symbolic Instruction Code ) is an  IDE  and  interpreter  for a variety of the  BASIC programming language  which is based on  QuickBASIC . Code entered into the IDE is compiled to an intermediate representation , and this  IR  is immediately interpreted on demand within the IDE. [1]  It can run under nearly all versions of  DOS  and  Windows , or through  DOSBox / DOSEMU , on  Linux  and...

Manchester Small-Scale Experimental Machine

Manchester Small-Scale Experimental Machine Replica of the Small-Scale Experimental Machine (SSEM) at the  Museum of Science and Industry  in Castlefield ,  Manchester The  Manchester Small-Scale Experimental Machine  ( SSEM ), nicknamed Baby , was the world's first  stored-program computer . It was built at the  Victoria University of Manchester , England, by  Frederic C. Williams ,  Tom Kilburn  and Geoff Tootill , and ran its first program on 21 June 1948. [1] The machine was not intended to be a practical computer but was instead designed as a  testbed  for the  Williams tube , an early form of computer memory. Although considered "small and primitive" by the standards of its time, it was the first working machine to contain all the elements essential to a modern electronic computer. [2]  As soon as the SSEM had demonstrated the feasibility of its design, a project was initiated at the university ...

Timeline of computing hardware 2400 BC–1949

Timeline of computing hardware 2400 BC–1949 This article presents a detailed  timeline  of events in the history of  computing hardware : from prehistory until 1949 . For narratives explaining the overall developments, see  History of computing . Contents Prehistory –1640 Edit Date Event 80000 BC Two notched rib bones may have been used for counting but they could have been merely decorative. [1] 18000 BC The  Ishango bone , may indicate that – even so early – material objects were used for simple arithmetical operations, and it may provide evidence of some knowledge of  prime numbers  (although this is disputed). [2] c. 2400 BC The  abacus  – the first known calculator, was probably invented by the  Babylonians  as an aid to simple  arithmetic around this time period. This laid the foundations for  positional notation  and later  computing  developments. c.   1115 BC The...