Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:20:35+00:00 2026-06-18T06:20:35+00:00

for passing arguments, pthread requires void pointer. I want to pass two variables, int

  • 0

for passing arguments, pthread requires void pointer. I want to pass two variables, int and long. To save myself some trouble, I will pass two long instead. So this is what I do:

int main(int argc, char *argv[])
{
   /*SOCKET INIT*/
   pthread_t socketTh;
   long data[2] = {ip2l(IP),80};
   pthread_create(&socketTh, 0, &serverConnect, (void*)data);   //ERROR HERE
   while(true) {
       /*event loop*/
   }
   quit_thread(&sockerTh);      //just an EXAMPLE! I don't know how to quit threads, I will google it later
   return 0;
 }

Error:

error: invalid conversion from ‘void (*)(void*)’ to ‘void* (*)(void*)’

But it seems that this is not the correct way to retype long pointer to void pointer. I wonder not of threads Stackoverflow has suggested me didn’t help, as well as any Google search. So maybe, try to explain it really slowly, because I’m beginner and I’m still lost in data types.
Thank you.

Update:
I create the unsigned long* in main(). This means this variable will last as long as the program itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:20:36+00:00Added an answer on June 18, 2026 at 6:20 am

    The error message refers to the third argument. pthread_create wants a pointer to a function that takes a void* and returns void*. Apparently the function serverConnect is a function that takes a void* and returns void.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help passing arguments to a jquery function. I have an html
When passing arguments to functions, the convention is to pass by value if the
I have two integer variables i and j and I want to make a
I am having problems with passing arguments to new threads, I have the following
Total noobie question here. I'm just learning Java, and studying passing arguments to functions.
It seems like g++ ignores difference in array sizes when passing arrays as arguments.
StructureMap doesn't like passing in Nullable types as constructor arguments. Is there a reason
How can one call a ColdFusion function, passing in attribute values as arguments, inside
warning: passing argument 1 of 'bsearch' makes pointer from integer without a cast and
main.c:78:25: erreur: assignment from incompatible pointer type [-Werror] main.c:81:9: erreur: passing argument 2 of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.