FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
June 01, 2006

Living By the Rules: Part II

(Page 5 of 6)

C99 Compatibility

One of the big language changes in C99 was the addition of the types long long int and unsigned long long int to the language. They've now been added to C++. This also requires some library additions to provide functions and format specifiers for these types. These library changes were made in TR1, and now, with TR1 incorporated into the C++ Standard, they'll be part of the Standard Library as well.

C99 also made some changes to the preprocessor, which will also become part of the C++ Standard. You can look forward to a new predefined macro, __STDC_HOSTED__, that expands to 1 for a hosted implementation or 0 otherwise. The _Pragma operator has been added, which provides an alternate way of writing pragmas. The benefit over using #pragma is that _Pragma can have a macro as its argument, and the macro will be expanded before being interpreted as a pragma. Syntactically, _Pragma takes a quoted string where #pragma takes a sequence of pp-tokens. The example from the Standard is:

#pragma listing on "..\listing.dir" _Pragma( "listing on \"..\\listing.dir\"" )

And, for those who really like macro programming, macros can now have variable-length argument lists. Here's one of the examples from the Standard:

#define debug(...) fprintf(stderr, __VA_ARGS__) debug("Flag"); debug("X = %d\n", x);

These work just the way you'd expect: __VA_ARGS__ is replaced by the arguments passed to the portion of the macro's argument list designated by the ellipsis [9].

Previous Page | 1 Living By the Rules: Part II | 2 Making Common Mistakes Legal | 3 Handy Extensions | 4 Library Interface Improvements | 5 C99 Compatibility | 6 Conclusion Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK