CAlive will introduce section {{..}} blocks, and a new reset command to reset those memory blocks to 0 by default, with an optional parameter allowing it to be reset to that byte value.
struct SExample
{
section linklist {{
struct SLinkList ll1;
struct SLinkList ll2;
}} // Since this one is not nested, doesn't need closing
// "section linklist" text
section data {{
section integers {{
int a;
int b;
int c;
int d;
section floats {{
union {
int ei;
float ef;
}
section integers }}
float f;
float g;
float h;
section floats }}
section data }}
};
In this example, there are four sections defined: linklist, data, integers, floats. Some sections overlap, but each one is defined within its {{ and }} named range.
It would allow commands like this:
struct SExample e;
reset e; // memset(&e, 0, sizeof(e));
reset e.linklist; // memset() only the linklist {{..}} members
reset e.data; // memset() only the data {{..}} members
reset e.integers; // memset() only the integers {{..}} members
reset e.floats; // memset() only the floats {{..}} members
In addition, it would allow member sections to be passed by address or reference, allowing for this:
my_function(&e.data);
void my_function(struct SExample.data* d)
{
// Reference only the SExample.data members here through d->
}
--
Rick C. Hodgin