1. Background
C language compilation error: error: initializer element is not constant. The error code is as follows:
char *info = (char *)malloc(len);
static char *info_t = info;
The above error is caused by trying to initialize a static variable with the memory pointer allocated by malloc.
2. Error reason
Static variable is a global variable. The value of the global variable cannot be determined at compile time, but at run time (compilation principle). Therefore, the global variable cannot be initialized directly with the return value of malloc at the time of declaration. Replace with the following:
char *info = (char *)malloc(len);
static char *info_t;
info_t = info;
Compilation passed.
Read More:
- Array initializer is not allowed here
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- Selenium reports an error and solves the problem of element not interactive exception, element not interactive
- [Error][IntelliJ IDEA] Element XXX is not allowed here
- Failed to execute ‘getComputedStyle’ on ‘Window’: parameter 1 is not of type ‘Element’.
- 2021-11-08 error: could not convert ‘{0}‘ from ‘<brace-enclosed initializer list>‘ to
- Uncaught Error: _registerComponent(…): Target container is not a DOM element
- Vue element UI uses this. $notify is not a function problem resolution using the notification box
- Element ‘dependency‘ cannot have character [children], because the type‘s content type is element-on
- Error: Target container is not a DOM element.
- There is no spring initializer solution when idea starts
- The total row of the Element table entry page is not displayed
- tf.contrib.layers .xavier_ Initializer function usage
- Property ‘style’ does not exist on type ‘element‘
- Vue + element, SCSS plus / deep / style does not work
- Expected unqualified ID before numeric constant
- Python + selenium drop-down list error message: element not interactive
- solve selenium.common.exceptions .ElementNotInteractableException: Message: element not interactable
- Expected unqualified ID before string constant
- error C2137: empty character constant