"Open Macro Library"

Syntax quick tour

Exceptions

Macros for management of exceptions for the C language, resembling the C++ syntax. Supports the definition of a hierarchy of application-specific exceptions, and the possibility to catch them from within catch statements.
#include <oml_exceptions/oml_exceptions.h>
#include <stdio.h>
#include <stdlib.h>

oml_define_exception(ENotReady) oml_extends(EException);

void f()
{
  oml_throw(ENotReady);
}

int main()
{
  oml_try
  {
    f();
  }
  oml_handle
      oml_when (EException)
      {
        printf("Exception caught !\n");
      }
  oml_end;

  char *my_mem;
  oml_try
  {
    my_mem = (char*) malloc(100);
    /* here some exception can be raised */
    oml_throw(ENotReady);
  }
  oml_finally
  {
    free(my_mem);
  }
  oml_handle
    oml_when(ENotReady)
    {
      printf("Exception caught !\n");
    }
  oml_end;

  return 0;
}

Latest news

2009-01-25
Deadline exception

2009-01-24
Exceptions for C Package

2009-01-16
Exceptions for the C language

2007-03-06
Syntax quick tour update.





Last update:
March 2, 2010