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

This is a discussion on warning: passing arg 3 of `pthread_create' from incompatible ... within the C Programming forums, part of the General Programming Boards category; Hello again, this is just something weird that I don't quite understand, maybe you can enlighten me. While trying to ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    > 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, 12: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21