Semaphore Error - Storage size of arg

G

Gvs

Hi,

I'm trying to compile an example semaphore .c file taken straight from the
internet, but it won't compile with the error;

gcc seminit.c -o seminit
seminit.c: In function `main':
seminit.c:16: error: storage size of 'arg' isn't known

Does anyone know how to correct this error.??

for reference the code is located at

http://www.ecst.csuchico.edu/~beej/guide/ipc/seminit.c

Any help would be much appreciated.

Kind Regards,

Matt
 
J

Jack Klein

Hi,

I'm trying to compile an example semaphore .c file taken straight from the
internet, but it won't compile with the error;

gcc seminit.c -o seminit
seminit.c: In function `main':
seminit.c:16: error: storage size of 'arg' isn't known

Does anyone know how to correct this error.??

for reference the code is located at

http://www.ecst.csuchico.edu/~beej/guide/ipc/seminit.c

Any help would be much appreciated.

Kind Regards,

Matt

There is no definition of the type 'enum semun', so it is an
incomplete type and you cannot define objects of an incomplete type.

This is not a standard C type, so presumably it is defined in one of
the three non-standard headers (the ones beginning with "sys/"), at
least on the implementation of the person who wrote the code.

That platform and implementation might or might be the same as yours,
and it might or might not have this type defined in one of those
headers. In any case, you need to take this to a group that supports
your compiler/operating system combination, because it is an extension
and not a type defined by the C language.
 
M

Martin Ambuhl

Gvs said:
Hi,

I'm trying to compile an example semaphore .c file taken straight from the
internet, but it won't compile with the error;

gcc seminit.c -o seminit
seminit.c: In function `main':
seminit.c:16: error: storage size of 'arg' isn't known

Does anyone know how to correct this error.??
for reference the code is located at
http://www.ecst.csuchico.edu/~beej/guide/ipc/seminit.c
Any help would be much appreciated.

Please post a small compilable program demonstrating your problem rather
than a URL.
Unfortunately,

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

make your example code non-standard and implementation-specific, so
off-topic here. Further, the calls of exit with an argument of 1 make
your code non-portable; the only values with standard meanings are 0,
EXIT_SUCCESS, and EXIT_FAILURE.

Your error message comes from this line:
union semun arg;
The meaning of "union semun" is expected by your code to be provided in
one of those non-standard header files. Apparently your versions of
these does not do so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top