473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

cast problem pthreads

my problem is probably simple to fix but I don't now how,
i have a thread function

void *display(struct Camera *camera)

and i try to create that thread via

pthread_create(&draw_thread, NULL, display, &camera);

when I compile with gcc it works,
using g++ there is an error:
invalid conversion from `void*(*)(Camera*)' to ` void*(*)(void*)'

where is the problem?
Jul 23 '05 #1
1 1681
Andreas Müller wrote:
void *display(struct Camera *camera)

and i try to create that thread via

pthread_create(&draw_thread, NULL, display, &camera);

when I compile with gcc it works,
using g++ there is an error:
invalid conversion from `void*(*)(Camera*)' to ` void*(*)(void*)'

where is the problem?


The problem is that pthread_create expects an argument of type

void*(*)(void*)

while you provided one of type

void*(*)(Camera*)
Solution: change display's signature so as for it to match pthread_create's
requirements, and cast the argument back to Camera * in the function's body.

Max




Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kevin Dahlhausen | last post by:
I've been playing with pySonic on unix. PySonic is pyrex wrapper around the fmod sound library. Fmod is distributed as a shared library that uses pthreads. I am getting a segfault when a...
5
by: Arnd Schroeter | last post by:
Hello! I am a c++ programmer under the os linux. I am using pthreads and i am wondering why i can only use satic methods of a class to create a thread of it. How can i change this, because it...
15
by: John David Ratliff | last post by:
Maybe someone here can help me. I want to use C++, but pthreads seems to be nonfunctional in it. The following test code I've written in C and C++. The C version works, while the C++ one does...
3
by: Andreas Müller | last post by:
i have a problem with threads and casts, I created a thread pthread_create(&grab_thread, NULL, grab_image, (void*)&camera); and my function is like this: void *grab_image(void *camera) {..} ...
5
by: Luke Dalessandro | last post by:
Code: Thread -> U -> T public class Thread { protected: thread_t _tid; virtual void foo() = 0; public: // Static entry function for the internal thread
6
by: Rouben Rostamian | last post by:
I ran into a few questionable C programming practices while reading a very nice tutorial on pthreads in: http://www.llnl.gov/computing/tutorials/workshops/workshop/pthreads For instance, in...
2
by: um | last post by:
When the POSIX pthreads library for w32 release 2-2-0 (http://sources.redhat.com/pthreads-win32/) is compiled with VC++6 then it compiles and passes all the benchmark tests in the subdirectory...
5
by: Ed L. | last post by:
Is this pthreads warning of any concern? gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -pthreads -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS...
8
by: Matt England | last post by:
My team currently using Boost Threads, but we are considering switching to ZThreads. (We seek cross-platform, C++ multithreading capabilities in an external library.) ZThread(s): ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.