forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDK sample for exceptions with C++

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> Patch Submissions
View previous topic :: View next topic  
Author Message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Fri Feb 20, 2009 7:52 pm    Post subject: SDK sample for exceptions with C++ Reply with quote

SDK sample for exceptions with C++

It seems that some people don't know how to use it.

Code:

Index: pspsdk/src/samples/Makefile.am
===================================================================
--- pspsdk/src/samples/Makefile.am   (working copy)
+++ pspsdk/src/samples/Makefile.am   (working copy)
@@ -81,7 +81,8 @@
    utility/osk \
    me/basic \
-   wlan
+   wlan \
+   exceptions
 
 all:
 
Index: pspsdk/src/samples/exceptions/main.cpp
===================================================================
--- pspsdk/src/samples/exceptions/main.cpp   (revision 0)
+++ pspsdk/src/samples/exceptions/main.cpp   (revision 0)
@@ -0,0 +1,50 @@
+#include <pspkernel.h>
+#include <pspdebug.h>
+#include <pspctrl.h>
+
+/* Define printf, just to make typing easier */
+#define printf  pspDebugScreenPrintf
+
+/* Define the module info section */
+PSP_MODULE_INFO("cppException", 0, 1, 1);
+
+/* Define the main thread's attribute value (optional) */
+PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
+
+#include <exception>
+using namespace std;
+
+class myexception: public exception
+{
+   virtual const char* what() const throw()
+   {
+      return "My exception happened";
+   }
+} myex;
+
+int main (void)
+{
+   pspDebugScreenInit();
+   SceCtrlData pad;
+   
+   try
+   {
+      throw myex;
+   }
+   catch (exception& e)
+   {
+      printf("%s\n", e.what());
+   }
+   
+   printf("\nPress X to quit.\n");
+
+   for (;;)
+   {
+      sceCtrlReadBufferPositive(&pad, 1);
+      if (pad.Buttons & PSP_CTRL_CROSS)
+         break;
+   }
+   sceKernelExitGame();
+
+   return 0;
+}
Index: pspsdk/src/samples/exceptions/Makefile.sample
===================================================================
--- pspsdk/src/samples/exceptions/Makefile.sample   (revision 0)
+++ pspsdk/src/samples/exceptions/Makefile.sample   (revision 0)
@@ -0,0 +1,18 @@
+TARGET = CppException
+OBJS = main.o
+LIBS = -lstdc++
+
+INCDIR =
+CFLAGS = -G0 -Wall -O2
+CXXFLAGS = $(CFLAGS) -fno-rtti -fexceptions
+ASFLAGS = $(CFLAGS)
+
+LIBDIR =
+LDFLAGS =
+
+EXTRA_TARGETS = EBOOT.PBP
+PSP_EBOOT_TITLE = C++ Exception Sample
+
+PSPSDK=$(shell psp-config --pspsdk-path)
+include $(PSPSDK)/lib/build.mak
+
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Feb 26, 2009 4:29 pm    Post subject: Reply with quote

I can't get it to apply, can you upload it somewhere (nopaste.org or similar)?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> Patch Submissions All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group