鉴于此结构:
struct PipeShm
{
int init;
int flag;
sem_t *mutex;
char * ptr1;
char * ptr2;
int status1;
int status2;
int semaphoreFlag;
};
这很好用:
static struct PipeShm myPipe = { .init = 0 , .flag = FALSE , .mutex = NULL ,
.ptr1 = NULL , .ptr2 = NULL , .status1 = -10 , .status2 = -10 ,
.semaphoreFlag = FALSE };
但是当我声明static struct PipeShm * myPipe
这不起作用时,我假设我需要使用操作符进行初始化->
,但是如何?
static struct PipeShm * myPipe = {.init = 0 , .flag = FALSE , .mutex = NULL ,
.ptr1 = NULL , .ptr2 = NULL , .status1 = -10 , .status2 = -10 ,
.semaphoreFlag = FALSE };
是否可以声明一个指向结构的指针并对其进行初始化?