Thread: Help - Struct Error

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    16

    Help - Struct Error

    I'm writing a thread pool that will contain reader threads, and am having a problem with the reader struct that I can't figure out. Please see the screen shots of my header files. The error propagates due to my reader pointer, but I can't see why, Any help on what could be wrong will be great.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I might be wrong here, but I suspect you want to add "typedef" before your struct declarations.... ie.

    Code:
    typedef struct thread_whatever{ ....

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    16
    No... Didn't do the trick. Thanks though.

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I find it hard to examine your code as images, but oh well. Next time, what might help is posting code in text format so we can actually compile it ourselves.

    Also, from what you're showing, you have issues in your .c file(s) which should be cleared up first imo.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    16
    I can't upload more than 5 files. So here a the few that cause the issue. Thanks.

  6. #6
    Registered User
    Join Date
    Jul 2008
    Posts
    16
    Here are 5 more.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    16
    And the rest.

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Well, my compiler is spitting out a lot of errors for me, even on the default warning level.

    I noticed that you're not showing all of the error messages.... You're supposed to deal with the first ones, not the last ones. Your structs may not be considered complete because you haven't defined all of the types inside of them. For example, I don't think ptask is defined by the time you get to reader.h. In your reader.c file you are including reader.h before task.h.

    I don't think I'll spend much more time on this. You should compile much more often before you generate this much code.

  9. #9
    * noops's Avatar
    Join Date
    Jun 2008
    Posts
    108
    Your screenshot says there are 4 errors but I can only see 3 due to the window scroll.

    What is the error?

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    16
    MacGyver (love the 'nick) - I use eclipse on linux and compile (gcc) on every save, and I only see 4 errors that are all related to that same reader problem. So I'm not sure why you're getting more - I'm pretty sure I included all the files. I tried changing the order of task.h and reader.h, but it didn't really make a difference. All of them have #ifndef tags, and I cleaned up things to see if that's the problem.

    noops - I have 3 errors, must have forgotten to hit save again. The error is propagated via the reader struct. Something is happening there that I can't trace, and it's bubbling down to other files.

    Thanks for your help - if you find anything, please let me know.

  11. #11
    Registered User
    Join Date
    Jul 2008
    Posts
    16
    I just realized I wrote I had 3 and 4 errors in the same post.. It's late here
    The real number is 3, and they are:
    reader.h: error: expected declaration specifiers or ‘...’ before ‘ptpool’ reader.h line 33
    thread_pool.h: error: expected specifier-qualifier-list before ‘preader’ thread_pool.h line 20
    thread_pool.h: error: expected ‘)’ before ‘pr’ thread_pool.h line 47

  12. #12
    * noops's Avatar
    Join Date
    Jun 2008
    Posts
    108
    thread_pool.h is including reader.h and reader.h is including thread_pool.h

  13. #13
    Registered User
    Join Date
    Jul 2008
    Posts
    16
    Wow, and that kept me debugging for 4 hours. Thanks for your help!

  14. #14
    * noops's Avatar
    Join Date
    Jun 2008
    Posts
    108
    By the way. I noticed you are still using the memcpy approach in your queue to store the data. That is an approach that may well work but then you could be using a lot of memory unnecessarily. Especially if you are going for a queue structure that is agnostic about the type of data it is organizing you might reconsider your approach.

    If you are interested, I can explain more.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  2. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM