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 mangling, exception 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

History of C++

History Edit Bjarne Stroustrup , the creator of C++ In 1979,  Bjarne Stroustrup , a Danish computer scientist, began work on the predecessor to C++, " C with  Classes ". [8]  The motivation for creating a new language originated from Stroustrup's experience in programming for his Ph.D. thesis. Stroustrup found that  Simula  had features that were very helpful for large software development, but the language was too slow for practical use, while  BCPL  was fast but too low-level to be suitable for large software development. When Stroustrup started working in  AT&T Bell Labs , he had the problem of analyzing the  UNIX   kernel  with respect to  distributed computing . Remembering his Ph.D. experience, Stroustrup set out to enhance the  C language with  Simula -like features. [9]  C was chosen because it was general-purpose, fast, portable and widely used. As well as C and Simula's influences, other ...

Compatibility of C and C++

Compatibility of C and C++ From Wikipedia, the free encyclopedia This article  needs additional citations for  verification .  Please help  improve this article  by  adding citations to reliable sources . Unsourced material may be challenged and removed.   (August 2013)   ( Learn how and when to remove this template message ) Programming language comparisons General comparison Basic syntax Basic instructions Exception handling Enumerated types Anonymous functions Conditional expressions Functional instructions Arrays Associative arrays String operations String functions List comprehension Object-oriented programming Object-oriented constructors While loops For loops Evaluation strategy List of "Hello World" programs Languages with dependent types Comparison of type systems Comparison of individual languages [show] v t e The  C  and  C++   programming languages ...

System partition and boot partition

System partition and boot partition From Wikipedia, the free encyclopedia System partition  and  boot partition  are computing terms for  disk partitions  of a  hard disk drive  that must exist and be properly configured for a system to operate correctly. There are two different definitions for these terms:  Microsoft  definition (used by  Windows ) and the common definition used by every other operating system. Common definition [ edit ] In context of every operating system, save those developed by  Microsoft Corporation , system partition and boot partition are defined as follows: The  boot partition  is a  primary partition  that contains the  boot loader , a piece of software responsible for booting the OS. For example, in the standard  Linux  directory layout ( Filesystem Hierarchy Standard ), boot files (such as the  kernel ,  initrd , and boot loader  GR...