KernelPollCallbacks?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
HexDump
Posts: 70
Joined: Tue Jun 07, 2005 9:18 pm

KernelPollCallbacks?

Post by HexDump »

Hi,

I have check some examples and KernelPollCallbacks appears, but it seems not to exist in pspsdk ( I did a full search on the pspsdk files), any idea?.


HexDump.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

That was a made up name, it's really called sceKernelSleepThreadCB().

As always look at the PSPSDK samples - it appears in the exit handler.
HexDump
Posts: 70
Joined: Tue Jun 07, 2005 9:18 pm

Post by HexDump »

thanks a lot MrBrown. A little more thing, I have copied and pasted the callback code from the example and I get this error

main.cpp invalid conversion from 'void (*)(void*)' to 'void*' .

It worked when I compled the example but not in my code. It is strange you should allways pass a Funcion name as a void*, any help please?.

NOTE: I´m compiling c++ code, and the example c code, perhaps this is the problem.

HexDump.
jimbo
Posts: 6
Joined: Thu Mar 31, 2005 2:30 am
Location: Sunny Southern CA
Contact:

Post by jimbo »

I am getting a similar error using psptoolchain-20050705.tgz and PSPSDK-svn rev 579(2005-7-10). I renamed main.c to main.cpp in the cube, wavegen, and fileio samples and I get the following errors:

Code: Select all

main.cpp: In function 'void CallbackThread(void*)':
main.cpp:39: error: invalid conversion from 'int (*)()' to 'void*'
main.cpp:39: error:   initializing argument 2 of 'int sceKernelCreateCallback(const char*, void*, void*)'
main.cpp: In function 'int SetupCallbacks()':
main.cpp:50: error: invalid conversion from 'void (*)(void*)' to 'int (*)(SceSize, void*)'
main.cpp:50: error:   initializing argument 2 of 'SceUID sceKernelCreateThread(const char*, int (*)(SceSize, void*), int, int, SceUInt, SceKernelThreadOptParam*)'
make: *** [main.o] Error 1
Does C++ use a different convention for function pointers?
Zeta
Posts: 9
Joined: Sat Jul 09, 2005 1:46 pm

Post by Zeta »

I think so. I tried the same and so that it would work I had to change any function as parameter to (void*)&nameoffunction. With this it worked fine.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

C++ has stricter type checking that C does, in C passing any pointer to void * will be autoconverted, in C++ it will complain. Either you do something like sceKernelCreateCallback("MyCallback", static_cast<void *>(CallbackThread), ...) or actually make sure your thread function has the correct prototype.
Zeta
Posts: 9
Joined: Sat Jul 09, 2005 1:46 pm

Post by Zeta »

That is much more correct and safe, I wish I wasn't so forgetful about type casting in c++ :(
Post Reply