0

I am trying to use a pthread library.

What is the cause of this error?

error C2664: 'pthread_create' : cannot convert parameter 3 from 'void *(__clrcall *)(void *)' to 'void *(__cdecl *)(void *)

Here's my code:

pthread_create(&thread1,NULL,sub_m,(void *)data);

void *sub_m(void* data)
3
  • 3
    Are you, by any chance, compiling your code as Managed C++? Commented Jan 15, 2016 at 21:16
  • I am using the visual studio 2010 Commented Jan 15, 2016 at 21:28
  • 1
    __clrcall in your error message makes me think the type of C++ project is Managed C++, not Native C++. Are you planning to use .NET Framework in your project? Actually, the solution provided by @toast should work, but disabling C++/CLI support (provided you don't need it) will not require to specify call convention explicitly. Commented Jan 15, 2016 at 21:46

1 Answer 1

0

make it void __cdecl sub_m(void *data). You are in managed code, so you need to get back into the proper calling convention.

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

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.