0
votes

I am doing a little application in C and I want to define a struct. I have done this :

typedef struct {
    ITEM element[TAILLE_TAMPON];
    sem_t mutex, attendreVide, attendrePlein;
    int ptEntree, ptSortie;
} TAMPON;

but I have an error when I built my project with ITEM Is it due to a problem with the include ?

  • stdio.h
  • stdlib.h
  • time.h
  • semaphore.h
  • pthread.h
  • "psleep.h"

"psleep.h" include "unistd.h"

Thank you for your help.

3
You should include the error of which you speak.dwc
How have you declared the ITEM type?Alex Martelli
So tempted to add the tag "tampon"Nosredna

3 Answers

4
votes

It sounds like in one of your headers the ITEM type was declared, although you need to give more information to be sure. Check to make sure you #include the file that defines the ITEM struct.

2
votes

No, it's not due to the includes at all. Given what you've shown us, it's due to ITEM not being a defined type.

0
votes

ITEM should be declared before the TAMPON. Did you perhaps try to declare it after the TAMPON?

Be sure that your include order guarantees that struct types you need to define other structs are brought in before the structs that refer to them. For example, if you have a BOX_OF_TAMPONS struct that uses TAMPON, you'd declare BOX_OF_TAMPONS after TAMPON.