我有一个我无法解决的愚蠢小问题......
exer3.c: In function ‘shm_pipe_pipe’:
exer3.c:69:39: error: expected ‘)’ before ‘;’ token
exer3.c:69:39: error: too few arguments to function ‘shmget’
/usr/include/i386-linux-gnu/sys/shm.h:54:12: note: declared here
line的69个环境:
pipes_array[i].m_key = 1;
key = i;
pipes_array[i].m_shmid = shmget(key, PIPE_SIZE, IPC_CREAT | IPC_EXCL | 0600); //69
if (pipes_array[i].m_shmid < 0) {
perror("Error");
return -1;
}
然后:
exer3.c: In function ‘shm_pipe_read’:
exer3.c:111:60: error: expected ‘)’ before ‘;’ token
line的111环境:
current_bytes_to_read = total_bytes_to_read <= pipes_array[i].m_bytes_in_pipe ? total_bytes_to_read : pipes_array[i].m_bytes_in_pipe;
//reading the information
if ((pipes_array[i].m_roffset + current_bytes_to_read) < PIPE_SIZE) { //111
memcpy(buf + offset, tbuffer + pipes_array[i].m_roffset, current_bytes_to_read);
然后: exer3.c:在函数'shm_pipe_write'中: exer3.c:153:41:错误:预期')'在';'标记
之前line的153环境:
while (total_bytes_to_write != 0) {
if (pipes_array[i].m_bytes_in_pipe == PIPE_SIZE) { //153
make: *** [exer3.o] Error 1
有人可以帮助我吗?谢谢!
答案 0 :(得分:10)
您的PIPE_SIZE宏可能如下所示:
#define PIPE_SIZE 100;
扔出分号(如果它们不存在则添加一些parens)。