www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - C1X going forward

reply bearophile <bearophileHUGS lycos.com> writes:
D is somewhat backwards compatible with C, you are also able to use the C std
library too. But what C? C89, C99 or C1X? GCC 4.6 introduces some features of
C1X. Some info about the upcoming standard:
http://en.wikipedia.org/wiki/C1X

In C1X there is _Noreturn, it seems interesting:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1453.htm
In C++0x it's [[noreturn]], and the nonstandard GCC extension is
__attribute__((noreturn)).

There are also the gets_s() function that replaces gets(), and aligned_alloc().

Bye,
bearophile
May 08 2011
next sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from bearophile (bearophileHUGS lycos.com)'s article
 D is somewhat backwards compatible with C, you are also able to use the C std
library too. But what C? C89, C99 or C1X? GCC 4.6 introduces some features of C1X. Some info about the upcoming standard:
 http://en.wikipedia.org/wiki/C1X
 In C1X there is _Noreturn, it seems interesting:
 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1453.htm
 In C++0x it's [[noreturn]], and the nonstandard GCC extension is
__attribute__((noreturn)).
 There are also the gets_s() function that replaces gets(), and aligned_alloc().
 Bye,
 bearophile
_Generic is a somewhat interesting feature of C1X too, though I can't imagine ever using any of the new features they've proposed. #define sqrt(X) _Generic((X), long double: sqrtl, \ default: sqrt, \ float: sqrtf)(X) float a = 25; auto b = sqrt(a); // calls sqrtf Oh, and they've also introduced a _Static_Assert keyword too. :)
May 09 2011
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Iain Buclaw" <ibuclaw ubuntu.com> wrote in message 
news:iq83hb$139t$1 digitalmars.com...
 == Quote from bearophile (bearophileHUGS lycos.com)'s article
 D is somewhat backwards compatible with C, you are also able to use the C 
 std
library too. But what C? C89, C99 or C1X? GCC 4.6 introduces some features of C1X. Some info about the upcoming standard:
 http://en.wikipedia.org/wiki/C1X
 In C1X there is _Noreturn, it seems interesting:
 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1453.htm
 In C++0x it's [[noreturn]], and the nonstandard GCC extension is
__attribute__((noreturn)).
 There are also the gets_s() function that replaces gets(), and 
 aligned_alloc().
 Bye,
 bearophile
_Generic is a somewhat interesting feature of C1X too, though I can't imagine ever using any of the new features they've proposed. #define sqrt(X) _Generic((X), long double: sqrtl, \ default: sqrt, \ float: sqrtf)(X) float a = 25; auto b = sqrt(a); // calls sqrtf Oh, and they've also introduced a _Static_Assert keyword too. :)
It's like they're turning C++ into a really, really ugly D :)
May 09 2011
parent Russel Winder <russel russel.org.uk> writes:
On Mon, 2011-05-09 at 14:29 -0400, Nick Sabalausky wrote:
[ . . . ]
 It's like they're turning C++ into a really, really ugly D :)
They talking about C not C++ -- C++0x is a start on the path to turning C++ into a beautiful language ;-) --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
May 09 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/9/2011 12:02 AM, Iain Buclaw wrote:
 _Generic is a somewhat interesting feature of C1X too, though I can't imagine
ever
 using any of the new features they've proposed.

 #define sqrt(X) _Generic((X), long double: sqrtl, \
                                default: sqrt, \
                                float: sqrtf)(X)

 float a = 25;
 auto b = sqrt(a);   // calls sqrtf
This cure is worse than the disease. Either put in real overloading, or not. Not this.
May 09 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Walter:

 This cure is worse than the disease.
 
 Either put in real overloading, or not. Not this.
Ignore _Generic(), but take a look at _Noreturn, gets_s() and aligned_alloc(). http://en.wikipedia.org/wiki/C1X Bye, bearophile
May 09 2011
parent Walter Bright <newshound2 digitalmars.com> writes:
On 5/9/2011 3:36 PM, bearophile wrote:
 take a look at _Noreturn, gets_s() and aligned_alloc().
 http://en.wikipedia.org/wiki/C1X
Those are trivialities; not worth bothering amending the standard for.
May 09 2011
prev sibling parent reply "Paulo Pinto" <pjmlp progtools.org> writes:
Do the new C standards still matter?

Most commercial C compilers are only C89 compliant, with a few C99 features 
on top, if any.

It seems that C89 is good enough for the tasks people still use C for, 
otherwise other languages are used and as such the
new features are not compeling to sell new compilers.

--
Paulo

"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:iq7ahc$2ud8$1 digitalmars.com...
D is somewhat backwards compatible with C, you are also able to use the C 
std library too. But what C? C89, C99 or C1X? GCC 4.6 introduces some 
features of C1X. Some info about the upcoming standard:
 http://en.wikipedia.org/wiki/C1X

 In C1X there is _Noreturn, it seems interesting:
 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1453.htm
 In C++0x it's [[noreturn]], and the nonstandard GCC extension is 
 __attribute__((noreturn)).

 There are also the gets_s() function that replaces gets(), and 
 aligned_alloc().

 Bye,
 bearophile 
May 09 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Paulo Pinto:

 Do the new C standards still matter?
I don't know.
 Most commercial C compilers are only C89 compliant, with a few C99 features 
 on top, if any.
Lately I compile C code with GCC and Clang. In Clang you don't even need a compiler switch to use C99, this is right.
 It seems that C89 is good enough for the tasks people still use C for, 
 otherwise other languages are used and as such the
 new features are not compeling to sell new compilers.
The adoption range is indeed slow. CPython sources are C89, and most large C projects I've seen don't use *all* C99 features, but this normal. I use C99 because is more handy and safer (example: local declaration of loop variables avoids a good amount of bugs). ----------------------- Iain Buclaw:
 _Generic is a somewhat interesting feature of C1X too, though I can't imagine
ever
 using any of the new features they've proposed.
_Generic looks a bit weird, it's meant to improve the usage for library code. I will probably use aligned_alloc(), alignment specifications. And once in a while _Noreturn. The Unicode support, anonymous structures and unions, and the static assertions that I use in D too.
 Oh, and they've also introduced a _Static_Assert keyword too. :)
This is useful, if well implemented. Bye, bearophile
May 09 2011