I recently started PSP development using C++ and I have a couple of questions. I apologize in advance if they are answered or RTFM, I goggled and searched in the forums, but without success.
a) first, regarding PRX exports. psp-build-exports generates a valid C file, but g++ chokes if we try to consider it as C++ file. For the time being, I want to export only either global functions or static member functions, so I need to solve name mangling issues only. I have done the following:
Makefile
Code: Select all
%.cc: %.exp
psp-build-exports -b $< > $@
LINK.cc=$(LINK.c)
Code: Select all
--- psp-build-exports.c.old 2007-01-26 12:12:09.000000000 +0100
+++ psp-build-exports.c 2007-01-26 12:29:36.000000000 +0100
@@ -335,7 +335,11 @@
pExp = pHead;
while(pExp != NULL)
{
+ fprintf(stdout, "#if defined (__STDC__) || defined(__cplusplus)\n");
+ fprintf(stdout, "extern char %s;\n", pExp->name);
+ fprintf(stdout, "#else\n");
fprintf(stdout, "void extern %s;\n", pExp->name);
+ fprintf(stdout, "#endif\n");
pExp = pExp->pNext;
}
}
@@ -399,14 +403,14 @@
{
if(strcmp(pLib->name, SYSTEM_LIB_NAME) == 0)
{
- fprintf(stdout, "\t{ NULL, ");
+ fprintf(stdout, "\t{ (const char*)NULL, ");
}
else
{
- fprintf(stdout, "\t{ \"%s\", ", pLib->name);
+ fprintf(stdout, "\t{ (const char*)\"%s\", ", pLib->name);
}
- fprintf(stdout, "0x%04X, 0x%04X, 4, %d, %d, &__%s_exports },\n", pLib->ver, pLib->attr,
+ fprintf(stdout, "0x%04X, 0x%04X, 4, %d, %d, (void*)&__%s_exports },\n", pLib->ver, pLib->attr,
pLib->varCount, pLib->funcCount, pLib->name);
pLib = pLib->pNext
b) what is the argp argument of s SceKernelThreadEntry? is there a way to make it a user pointer so a given thread object or task can be passed? Apparently there seems to be no way to pass a user pointer to sceKernelCreateThread
Code: Select all
namespace psp {
// Task is a template parameter with a class that
// implements i_runnable (e.g. has a run() method)
template<typename Task>
class thread
{
static int func (SceSize n, void* p)
{
static_cast<Task*>(p)->run();
....
}
...
int create (...)
{
m_thid = ::sceKernelCreateThread (m_name.c_str(), thread::func...)
}
}
Many thanks in advance