#include "test.h" #define MKEY 0x2222 int testmatshm() { int shmid = -1; void *shmp; shmid = shmget(MKEY, 1024, IPC_CREAT | IPC_EXCL | OBJ_PERMS); if (shmid == -1 && errno == EEXIST) { printf("first create\n"); shmid = shmget(MKEY, 0, 0); } if (shmid == -1) err_exit(errno, "testmatshm shmget"); shmp = shmat(shmid, NULL, 0); } typedef struct buf_t { char buf[7]; } buf_t; void test(int size) { char buf[size]; printf("size = %d\n", sizeof(buf)); } char msg[10]; int main() { // testmatshm(); // testmatshm(); // sleep(60); // printf("size = %d, msg = %d\n", sizeof(buf_t), sizeof(msg)); test(12); }