libc8
CHIP-8 utility library
Loading...
Searching...
No Matches
exception.h File Reference
#include <stdio.h>

Go to the source code of this file.

Macros

#define C8_EXCEPTION_MESSAGE_SIZE   BUFSIZ
 Maximum size of exception message.
 
#define C8_EXCEPTION(code, ...)
 Exception handling macro.
 

Enumerations

enum  C8_ExceptionCode {
  C8_INVALID_INSTRUCTION_EXCEPTION = -3 , C8_TOO_MANY_LABELS_EXCEPTION = -4 , C8_STACK_OVERFLOW_EXCEPTION = -5 , C8_INVALID_ARGUMENT_EXCEPTION = -6 ,
  C8_DUPLICATE_LABEL_EXCEPTION = -7 , C8_INVALID_SYMBOL_EXCEPTION = -8 , C8_MEMORY_ALLOCATION_EXCEPTION = -9 , C8_UNKNOWN_EXCEPTION = -10 ,
  C8_TOO_MANY_SYMBOLS_EXCEPTION = -11 , C8_LOAD_FILE_FAILURE_EXCEPTION = -12 , C8_FILE_TOO_BIG_EXCEPTION = -13 , C8_INVALID_COLOR_PALETTE_EXCEPTION = -14 ,
  C8_INVALID_QUIRK_EXCEPTION = -15 , C8_FAILED_GRAPHICS_INITIALIZATION_EXCEPTION = -16 , C8_INVALID_FONT_EXCEPTION = -17 , C8_INVALID_CLOCK_SPEED_EXCEPTION = -18 ,
  C8_STACK_UNDERFLOW_EXCEPTION = -19
}
 Exception code enum. More...
 

Functions

void c8_handle_exception (C8_ExceptionCode)
 Handles an exception by printing the corresponding error message to stderr.
 

Variables

char c8_exception [BUFSIZ]
 Message to print when calling c8_handle_exception with a non-zero code.
 

Detailed Description

Note
NOT EXPORTED

Stuff for handling exceptions.

Macro Definition Documentation

◆ C8_EXCEPTION

#define C8_EXCEPTION (   code,
  ... 
)
Value:
{ \
snprintf(c8_exception, C8_EXCEPTION_MESSAGE_SIZE, __VA_ARGS__); \
c8_handle_exception(code); \
}
char c8_exception[BUFSIZ]
Message to print when calling c8_handle_exception with a non-zero code.
Definition: exception.c:65
#define C8_EXCEPTION_MESSAGE_SIZE
Maximum size of exception message.
Definition: exception.h:16

Exception handling macro.

◆ C8_EXCEPTION_MESSAGE_SIZE

#define C8_EXCEPTION_MESSAGE_SIZE   BUFSIZ

Maximum size of exception message.

Enumeration Type Documentation

◆ C8_ExceptionCode

Exception code enum.

Enumerator
C8_INVALID_INSTRUCTION_EXCEPTION 
C8_TOO_MANY_LABELS_EXCEPTION 
C8_STACK_OVERFLOW_EXCEPTION 
C8_INVALID_ARGUMENT_EXCEPTION 
C8_DUPLICATE_LABEL_EXCEPTION 
C8_INVALID_SYMBOL_EXCEPTION 
C8_MEMORY_ALLOCATION_EXCEPTION 
C8_UNKNOWN_EXCEPTION 
C8_TOO_MANY_SYMBOLS_EXCEPTION 
C8_LOAD_FILE_FAILURE_EXCEPTION 
C8_FILE_TOO_BIG_EXCEPTION 
C8_INVALID_COLOR_PALETTE_EXCEPTION 
C8_INVALID_QUIRK_EXCEPTION 
C8_FAILED_GRAPHICS_INITIALIZATION_EXCEPTION 
C8_INVALID_FONT_EXCEPTION 
C8_INVALID_CLOCK_SPEED_EXCEPTION 
C8_STACK_UNDERFLOW_EXCEPTION 

Function Documentation

◆ c8_handle_exception()

void c8_handle_exception ( C8_ExceptionCode  code)

Handles an exception by printing the corresponding error message to stderr.

Parameters
codeThe exception code.

Variable Documentation

◆ c8_exception

char c8_exception[BUFSIZ]
extern

Message to print when calling c8_handle_exception with a non-zero code.