Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/compilation_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 54 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,69 @@
# C Traceback
A colorful, lightweight error-propagation framework for C.

Website: [https://www.ctraceback.com](https://www.ctraceback.com)
Documentation Website: [https://www.ctraceback.com](https://www.ctraceback.com)

**This library is in early development. Stay tuned!**
![C Traceback](.github/compilation_info.png)

## Features
* Beautiful tracebacks
* Exceptions in C
* Works with Signal Handlers
* Fast and Thread-safe
* Explicit control flow
* Thread-safe
* Low performance overhead
* Written in C99 with minimal dependencies
* Works with MSVC, Clang and GCC
* Written in C99 with minimal dependencies
* Detailed documentations

## To-dos before first release
* Test MSVC
* Finish docs
## Sample usage
```c
#include <stdio.h>
#include "c_traceback.h"

#define N 100

static void do_calculation(double *vec);

int main(void)
{
ctb_clear_context();
ctb_install_signal_handlers();

double *vec = malloc(N * sizeof(double));
if (!vec)
{
THROW(CTB_MEMORY_ERROR, "Failed to allocate memory");
goto error;
}

TRY_GOTO(do_calculation(vec), error);
printf("This shouldn't be printed if there is error");

free(vec);
return 0;

error:
free(vec);
ctb_dump_traceback(); // Log traceback and reset context
return 0;
}

static void do_calculation(double *vec)
{
// Initialize array
for (int i = 0; i < N; i++)
{
vec[i] = 0;
}

// Calculations
for (int i = 0; i < N; i++)
{
vec[i] += 10;
}
}
```

## Support Us
* ⭐ Give us a star
* ❤️ Sponsor
<!-- * ❤️ Sponsor -->
* 👤 [Follow](https://github.com/alvinng4)
2 changes: 1 addition & 1 deletion src/error_codes.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ const char *warning_to_string(CTB_Warning warning)
default: return "Unknown Warning";
}
}
// clang-format on
// clang-format on