Thread: warning: passing arg 3 of `pthread_create' from incompatible ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    41

    Question warning: passing arg 3 of `pthread_create' from incompatible ...

    Hello again,
    this is just something weird that I don't quite understand, maybe you can enlighten me. While trying to get rid of all the compiler warnings, I found this warning:
    "warning: passing arg 3 of `pthread_create' from incompatible poin
    ter type"

    It is generated by this line:
    pthread_create(&unused_id, NULL, chat_stream, &clntsock);

    The chat_stream function looks like this:
    void chat_stream(int *newsock)
    {
    ...
    }

    This actually works flawlessly, so why does it give me a warning? This is exactly how it's done in the example at http://www.cs.cf.ac.uk/Dave/C/node29.html (I think).

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    pthread_create is prototyped as

    >int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start)(void *), void *arg);

    I'm going to guess your problem is that the highlighted section doesn't match your function:

    >void chat_stream(int *newsock)
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > This is exactly how it's done in the example
    Your function has a different type
    - you pass it different arguments
    - it returns different results

    To be blunt
    Code:
    void *chat_stream(void *p) 
    {
        int *newsock = p;
        return NULL; 
    }

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    41
    Thanks, it's working now!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 08-12-2007, 05:26 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM