HP C B.11.11.16 Release Notes

HP C/ANSI C Release Notes
What’s in This Version
Chapter 1 7
The following rules govern the flexible array members:
A flexible array member must be the last member of the structure.
The structure must contain at least one named member other than the flexible array
member.
A structure containing the flexible array member cannot be a member of another
structure or element of an array.
A structure containing, possibly recursively, a flexible array member, cannot be a member
of a union.
Flexible array members are more useful while reading records from the command-line and
retrieving information of variable length.
For example, consider the following code:
#include <stdio.h>
#include <stdlib.h>
struct A {
int a;
int b[1];
};
int main() {
const int N = 10;
int i;
struct A* p = malloc(sizeof(struct A) +
sizeof(int) * (N - 1));
p->a = 100;
for (i = 0; i < N; i++)
p->b[i] = i;
printf("%d %d %d\n", p->a, p->b[0], p->b[N-1]);
return 0;
}
Following is the modified code using flexible array members:
struct A {
...
int b[];
};
int main() {
...
struct A* p = malloc(sizeof(struct A) +