static struct Queueptr * Header = (struct queueptr *) malloc (sizeof (struct queueptr));
Wrong in compile times: initializer element is not constant
Reason: Indicates that the initialization of global and static variables must be constant expressions in C99
Modify:
static struct Queueptr * Header = NULL;
Header = (struct queueptr *) malloc (sizeof (struct queueptr)));
Check out the other blogs and see that the following code will also report the same error:
Link: Why "initializer element is not constant" error appears
#include <stdio.h>
int a = 1;
int b = 2;
int c = a+b;
int main () {
printf ("C is%d\n", c);
return 0;
}
Similarly, the value of global variable C in the above code is determined at execution time. The initialization of a global variable is done at compile time, so it cannot be a variable whose value has not yet been determined.
(1) The initialization of global and static variables in C language needs to specify a constant, which cannot be a very variable expression;
(2) as a global variable, after compiling to determine its address, if the global variable is a structural body, then the structure of the individual members of the specific values to be determined. Because a global variable is stored in a static area, only a constant expression can determine the value in advance, rather than the specific run-time determination.
(3) Basis:
C99 Standard 6.7.8 Initialization 4th paragraph:
4 the expressions in a initializer for a, has static storage duration shall be constant expressions or St Ring literals.