0

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
  • 2
    You should include the error of which you speak. Commented May 31, 2009 at 15:59
  • 2
    How have you declared the ITEM type? Commented May 31, 2009 at 16:01
  • 1
    So tempted to add the tag "tampon" Commented May 31, 2009 at 16:17

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

2 Comments

well, yes, it's probably due to ITEM not being a defined type...because he didn't include where it was defined.
My error come from the definition of ITEM. I forgot to make a typedef enum {...} ITEM; I thought that it was a problem with the struct. Thank you for your help.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.