Skip to content
/ Debug Public

A header-only implementation of macros able to output information. Able to be set using gcc -D DEBUG_ENABLE.

Notifications You must be signed in to change notification settings

t-m-e/Debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Debug

Small header-only implementation of debug statements that can be enabled/disabled with environment variables.

Compile your code with gcc -D DEBUG_ENABLE ... and you will be able to enable these macros. Otherwise, if -D DEBUG_ENABLE isn't found or #define DEBUG_ENABLE isn't defined in the source, the macros will be empty statements.

Example

For errors with normal execution:

#include "debug.h"

int main() {
    DEBUG_INFO("Hello, World!");
    DEBUG_WARN("Hello, but spicy.");
    DEBUG_ERR("Hello, but handle error.");
    return 0;
}

Will output:

(file.c:4 INFO) Hello, World!
(file.c:5 WARN) Hello, byt spicy.
(file.c:6 ERR) Hello, but handle error.

For fatal errors:

#include "debug.h"

int main() {
    DEBUG_FATAL("Hello, but Goodbye!");
    return 0;
}

Will output:

(file.c:4 FATAL) Hello, but Goodbye! | exiting.

For abortable errors:

#include "debug.h"

int main() {
    DEBUG_ABORT("Hello, but die.");
    return 0;
}

Will output:

(file.c:4 ABORT) Hello, but die. | killing process.

About

A header-only implementation of macros able to output information. Able to be set using gcc -D DEBUG_ENABLE.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages