C
Christian Christmann
Hi,
I have problems to initialize a static struct. Here is the meaningful
part of the code:
int main()
{
int pA = -100;
struct globalMixed4 {
int a;
int *b;
};
static struct globalMixed4 globMix4 =
{ 200, &pA }; // my line 70
When try to compile, I get the gcc error message:
struct.c:70: error: initializer element is not constant
The non-constant initializer element is &pA.
How can I make it const?
And in general, why does the compiler expect a const initializer?
Thank you.
Chris
I have problems to initialize a static struct. Here is the meaningful
part of the code:
int main()
{
int pA = -100;
struct globalMixed4 {
int a;
int *b;
};
static struct globalMixed4 globMix4 =
{ 200, &pA }; // my line 70
When try to compile, I get the gcc error message:
struct.c:70: error: initializer element is not constant
The non-constant initializer element is &pA.
How can I make it const?
And in general, why does the compiler expect a const initializer?
Thank you.
Chris