Are you looking for something like this?
#include <stdlib.h>
typedef struct {
const char* name;
} Item;
int main() {
Item* item = malloc(sizeof(Item));
*item = (Item){.name = "Hello"};
// do work
free(item);
return 0;
}
Compiles with GCC 10.2.0 -Wall -Wextra
with no errors or warnings.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…