Better makefile, restructured, more demos

This commit is contained in:
2011-07-30 23:21:17 -04:00
parent b233356ad3
commit 1c280a8cde
9 changed files with 129 additions and 136 deletions

23
demo/single.c Normal file
View File

@@ -0,0 +1,23 @@
#include "exclib.h"
/*
* What this demo shows:
* 1- The general usage of this library
* 2- That a basic usage example works
*/
int main(void)
{
EXCLIB_TRACE("No stack to print?");
TRY {
THROW(3, NULL);
} CATCH(3) {
EXCLIB_TRACE("Caught 3");
} ETRY;
EXCLIB_TRACE("Exiting program");
return 0;
}

16
demo/threelevel.c Normal file
View File

@@ -0,0 +1,16 @@
#include "exclib.h"
int main(void)
{
TRY {
TRY {
THROW(3, NULL);
} CATCH(5) {
EXCLIB_TRACE("Caught 5");
} ETRY;
} CATCH(3) {
EXCLIB_TRACE("Caught 3");
} ETRY;
return 0;
}

21
demo/trypair.c Normal file
View File

@@ -0,0 +1,21 @@
#include "exclib.h"
int main(void)
{
TRY {
THROW(3, NULL);
} CATCH(3) {
} ETRY;
TRY {
THROW(3, NULL);
} CATCH(3) {
TRY {
THROW(3, NULL);
} ETRY;
} ETRY;
EXCLIB_TRACE("Should never get here");
return 0;
}

21
demo/twolevel.c Normal file
View File

@@ -0,0 +1,21 @@
#include "exclib.h"
/*
* What this example shows:
* 1- That an exception will propagate up out of the current TRY/CATCH context
* 2- That an uncaught exception will generate an error
*/
int main(void)
{
TRY {
THROW(3, NULL);
} CATCH(3) {
THROW(3, NULL);
} ETRY;
EXCLIB_TRACE("Should never get here");
return 0;
}