Skip to content

Commit 5ee7412

Browse files
authored
Update README
* Update README.md * Add screenshot * Update README.md
1 parent edfdc5f commit 5ee7412

3 files changed

Lines changed: 55 additions & 11 deletions

File tree

.github/compilation_info.png

598 KB
Loading

README.md

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,69 @@
11
# C Traceback
22
A colorful, lightweight error-propagation framework for C.
33

4-
Website: [https://www.ctraceback.com](https://www.ctraceback.com)
4+
Documentation Website: [https://www.ctraceback.com](https://www.ctraceback.com)
55

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

88
## Features
99
* Beautiful tracebacks
10-
* Exceptions in C
10+
* Works with Signal Handlers
11+
* Fast and Thread-safe
1112
* Explicit control flow
12-
* Thread-safe
13-
* Low performance overhead
14-
* Written in C99 with minimal dependencies
1513
* Works with MSVC, Clang and GCC
14+
* Written in C99 with minimal dependencies
1615
* Detailed documentations
1716

18-
## To-dos before first release
19-
* Test MSVC
20-
* Finish docs
17+
## Sample usage
18+
```c
19+
#include <stdio.h>
20+
#include "c_traceback.h"
21+
22+
#define N 100
23+
24+
static void do_calculation(double *vec);
25+
26+
int main(void)
27+
{
28+
ctb_clear_context();
29+
ctb_install_signal_handlers();
30+
31+
double *vec = malloc(N * sizeof(double));
32+
if (!vec)
33+
{
34+
THROW(CTB_MEMORY_ERROR, "Failed to allocate memory");
35+
goto error;
36+
}
37+
38+
TRY_GOTO(do_calculation(vec), error);
39+
printf("This shouldn't be printed if there is error");
40+
41+
free(vec);
42+
return 0;
43+
44+
error:
45+
free(vec);
46+
ctb_dump_traceback(); // Log traceback and reset context
47+
return 0;
48+
}
49+
50+
static void do_calculation(double *vec)
51+
{
52+
// Initialize array
53+
for (int i = 0; i < N; i++)
54+
{
55+
vec[i] = 0;
56+
}
57+
58+
// Calculations
59+
for (int i = 0; i < N; i++)
60+
{
61+
vec[i] += 10;
62+
}
63+
}
64+
```
2165
2266
## Support Us
2367
* ⭐ Give us a star
24-
* ❤️ Sponsor
68+
<!-- * ❤️ Sponsor -->
2569
* 👤 [Follow](https://github.com/alvinng4)

src/error_codes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ const char *warning_to_string(CTB_Warning warning)
111111
default: return "Unknown Warning";
112112
}
113113
}
114-
// clang-format on
114+
// clang-format on

0 commit comments

Comments
 (0)