Re: union variable error(storage size isn't known)
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 26 Dec 2006 17:13:58 GMT
Ronald <followait@xxxxxxx> wrote:
union semun semun0;
semun0.val=1;
There is an error when compiling, that is like below.
storage size of 'semun0' isn't known
Then you probably have forgotten to include the header file where
the union is defined. Or it's not defined anywhere and you have to
define it yourself.
Since I guess it's about shared memory and you might be reading
Stevens APUE: The prototype for the semctl() function has been
changed since the time APUE was published, it's prototype is
now
int semctl(int semid, int semnum, int cmd, ...);
and the semun union isn't defined in <sys/sem.h> anymore - the
newer POSIX standards actually discourages implementations from
defining it. You have to define it yourself like this:
#if defined ( _SEM_SEMUN_UNDEFINED )
union semun {
int val; /* value for SETVAL */
struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
unsigned short int *array; /* array for GETALL, SETALL */
struct seminfo *__buf; /* buffer for IPC_INFO */
};
#endif
(If you want to follow the POSIX standard you should leave out the
last, '__buf' pointer, that's Linux specific.)
The test of _SEM_SEMUN_UNDEFINED is there to get the program to
compile also on rather old Linux versions where the semun union
still was defined in the headers.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- References:
- union variable error(storage size isn't known)
- From: Ronald
- union variable error(storage size isn't known)
- Prev by Date: Re: hi frnd pls guide me regarding how to compile in linux2.10.18
- Next by Date: Re: PCI device driver question
- Previous by thread: union variable error(storage size isn't known)
- Index(es):
Relevant Pages
|