请编程高手指教% F5 W% k5 s0 t
/ i" w& O, g& |% ]+ o: k2 f& N
我在学unix进程间通信----SYSTEM V消息队列的时候遇到如下问题# }; p- w8 y/ a2 o6 @
[root@localhost svmsg]# make
7 G+ |. P# y' q7 vgcc -g -O2 -D_REENTRANT -Wall -c -o ctl.o ctl.c" y, L( K* Y6 A
- n, }6 r) s. }ctl.c: In function `main':
8 t- o J( O3 p5 hctl.c:8: storage size of `buf' isn't known
7 L: F9 z7 P1 J1 c7 V7 ]9 vctl.c:10: `MSG_R' undeclared (first use in this function)
, X. a; a0 `) H( s8 y q+ O4 tctl.c:10: (Each undeclared identifier is reported only once
# D* t( ?( Q) W7 j6 l) T9 B: qctl.c:10: for each function it appears in.)
& B+ q" }( y8 p, `0 r; {( @ctl.c:10: `MSG_W' undeclared (first use in this function)% Q. h1 Q* t: d: G @( A
ctl.c:18: `ulong_t' undeclared (first use in this function)% c: j+ v0 `) S) Q
. P: i3 O- N4 Z0 b: w8 u6 t
4 k1 k& ^1 J- s6 B* ^5 J0 j% A下面是ctl.c文件
, M$ }, }. n/ V" e% w$ D#include "unpipc.h"/ T9 z0 E' T( i6 w7 _0 N
% N% z. N( V' j" F! E9 Sint
: x5 Q' e) A% I2 X% Ymain(int argc, char **argv)
5 }* d! n8 c# U0 M( {% S{4 n$ p2 E1 i3 L) P" I% }
int msqid;
; ?3 \% O# V: p: S! g+ Y struct msqid_ds info;
2 B9 H9 \1 O1 y: P4 @! o8 p4 F struct msgbuf buf;/*问题所在处*/# ]2 c# o. Y; I7 K
3 L( i1 t! f' e- f* [& v
msqid = Msgget(IPC_PRIVATE, SVMSG_MODE | IPC_CREAT);/*问题所在处*/3 x6 G. A) P) d. Y7 Q% p- M! v4 y3 I
0 ?$ `, t8 d5 Z8 x/ ^
3 n5 C, r" L4 L
/*other code*/% l' c+ d8 a' A/ ?/ ?
}
3 C/ d, x5 R8 a! Y: d
- i5 l; E3 n% ^+ r' T, z( `% |" }% H2 K
下面是unpipc.h文件节选
( e4 D9 W, v& }0 o. V2 G- O#ifdef HAVE_SYS_MSG_H# ]# M6 C8 ?! O# n+ C& E. [2 o
# include <sys/msg.h> /* System V message queues */
1 U1 I5 y* M8 L& V1 U, E/ b2 v#endif
1 o a1 F1 M8 }
X: J- Z4 |1 L( I* f8 v& v# t6 s. i) [! @; ^1 l% d* b
#define SVMSG_MODE (MSG_R | MSG_W | MSG_R>>3 | MSG_R>>6)/*问题所在处*/6 V. w# h: }$ c2 |0 a/ ?
/* default permissions for new SV message queues */
+ j! y$ ?- g5 |& @. Q5 V( j3 L/* $$.ix [SVMSG_MODE]~constant,~definition~of$$ */
% Y) U" d/ N c# Y
: f; J% q# e7 ^
V4 T- o& v4 b7 _下面是<sys/msg.h>文件
( [: F" {$ z, g#ifdef __USE_GNU; |7 X2 g; r+ y
/* Template for struct to be used as argument for `msgsnd' and `msgrcv'. */
5 t) `% ^2 ^4 _. tstruct msgbuf
1 m( m% N6 g: } {6 ~+ I+ B" ]* |' b) F' @
long int mtype; /* type of received/sent message *// G3 M6 h( u3 H; F
char mtext[1]; /* text of the message */* A) t' V6 |; S: E8 Z, A4 u5 d
};
- v9 W- e) r1 \) t& K5 i#endif
; r; \" U6 p; _1 w0 Z' q5 I
5 t; W9 a3 N8 F+ T2 M0 H0 N请各大虾多多指教!!(我用的是linux7.0)
, `' M! A8 s" }) V1 _5 v8 t8 L U