C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

The components of div_t, quot and rem, are initialized to 2 and -1, respectively.
Previously, you would initialize the struct components as follows:
typedef struct div_t {
int quot;
int rem;
} div_t;
div_t answer = {2, -1};
Nonconstant Aggregate Component Initializers
The initializer expression for an automatic composite variable can contain nonconstant
subexpressions. [6.7.8, Initialization]
Example
typedef struct whole {
int part1;
int part2;
} whole;
void foo (int i, int j) {
whole local_var = {i, j};
Previously, only constants were allowed in the initializer expressions; nonconstant initialization
required an assignment statement.
Mixed Statements and Declarations
Declarations can appear within a block. Previously, this was an error. [6.8.2, Compound statement]
Example
{
foo();
int i = 1; //no longer an error
bar(i);
}
New Block Scopes for Selection and Iteration Statements
All selection statements (if, if/else, and switch statements) and iteration statements (while,
do/while, and for statements) and their associated substatements are considered to be blocks.
[6.8.4, Selection statements, and 6.8.5, Iteration statements]
Example
int i = 42;
for (int i=5, j=15, i<10; i++, j--) // i and j are accessible
// only within this loop
// statement
printf ("loop %i %i\n", i, j); // prints the values of i and
// j defined within the loop
printf ("i = %i\n", i); // prints i = 42
intmax for Preprocessor Expressions
Preprocessor expressions are evaluated using intmax_t and uintmax_t. intmax_t and
uintmax_t are defined in <stdint.h> to be long long and unsigned long long, respectively.
Previously, int and unsigned int, respectively, were used. [6.10.1, Conditional inclusion]
Variadic Macros
Variadic function-like macros are allowed. A variadic macro is a macro that can be declared to
have a variable number of arguments. [6.10.3, Macro replacement]
Nonconstant Aggregate Component Initializers 459