What are features from the actual C Standard, which originally weren´t part of C, but were invented in/for C++ and because of its benefits, were later adopted to C?
One prominent example is the single-line comment //
, which originally came from C++ and later was adopted by C.
Do you know more features of the actual C Standard, which explicitly or implicitly came from the development of C++?
Info: Of course, I know that C++ is derived from C but i was just thinking about which features was adopted from the development of its derivative, C++.
I cannot confirm that they were definitely influenced by C++ directly1, but here is a list of features in standard C++ that were added in C99:
C11:
1 For example BCPL, predecessor of B which in turn is the predecessor of C already had same syntax for single line comments. Some of these may have been supported as language extensions in some C implementation prior to their incorporation to standard C++. In these cases both standard C and standard C++ may have been influenced by the same source, rather than influencing one another.
Attributes were added in C++11 and will be added in the next C standard revision C2x. The proposal (and here) for this feature specifically references C++.
Attributes can be useful for providing information that, for example, helps the compiler to issue better diagnostics or optimize the generated code. Source
Example:
int [[attr1]] i [[attr2, attr3]];
[[attr4(arg1, arg2)]] if (cond)
{
[[vendor::attr5]] return i;
}
In this example, "attribute attr1 applies to the type of variable i, attr2 and attr3 apply to the variable itself, attr4 applies to the if statement and vendor::attr5 applies to the return statement." Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With