J
John Reye
Is the existance-scope of struct literals, identical to that of
declared variables?
i.e. the "existance"-scope goes until the end of the current { } -
delimited block, or the scope is global if it's outside any block.
Example:
#include <stdlib.h>
struct y
{
struct y *num;
int a;
};
struct x
{
struct y *x;
};
#define x(num) (&(struct y){NULL, (num)}) /* macro generates a struct
literal and returns a pointer to it */
int main(void)
{
int i;
struct y *tmp;
{
tmp = x(1);
}
/* here the storage at pointer tmp cannot be accessed anymore,
right? The literal struct is no longer in scope, right?*/
return EXIT_SUCCESS;
}
PS:
How does one officially call (what I have irreverently termed...)
"existence"-scope?
Thanks.
declared variables?
i.e. the "existance"-scope goes until the end of the current { } -
delimited block, or the scope is global if it's outside any block.
Example:
#include <stdlib.h>
struct y
{
struct y *num;
int a;
};
struct x
{
struct y *x;
};
#define x(num) (&(struct y){NULL, (num)}) /* macro generates a struct
literal and returns a pointer to it */
int main(void)
{
int i;
struct y *tmp;
{
tmp = x(1);
}
/* here the storage at pointer tmp cannot be accessed anymore,
right? The literal struct is no longer in scope, right?*/
return EXIT_SUCCESS;
}
PS:
How does one officially call (what I have irreverently termed...)
"existence"-scope?
Thanks.