standalone: use C++ casting in demo.c
This commit is contained in:
parent
99da1974ef
commit
6354e99320
|
@ -52,7 +52,7 @@ struct cslice {
|
||||||
};
|
};
|
||||||
|
|
||||||
void output_int32_list(struct cslice *slice) {
|
void output_int32_list(struct cslice *slice) {
|
||||||
const int32_t *data = (int32_t *)slice->data;
|
const int32_t *data = reinterpret_cast<int32_t *>(slice->data);
|
||||||
|
|
||||||
putchar('[');
|
putchar('[');
|
||||||
for (size_t i = 0; i < slice->len; ++i) {
|
for (size_t i = 0; i < slice->len; ++i) {
|
||||||
|
@ -67,7 +67,7 @@ void output_int32_list(struct cslice *slice) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void output_str(struct cslice *slice) {
|
void output_str(struct cslice *slice) {
|
||||||
const char *data = (const char *)slice->data;
|
const char *data = reinterpret_cast<const char *>(slice->data);
|
||||||
|
|
||||||
for (size_t i = 0; i < slice->len; ++i) {
|
for (size_t i = 0; i < slice->len; ++i) {
|
||||||
putchar(data[i]);
|
putchar(data[i]);
|
||||||
|
@ -81,7 +81,7 @@ void output_strln(struct cslice *slice) {
|
||||||
|
|
||||||
uint64_t dbg_stack_address(__attribute__((unused)) struct cslice *slice) {
|
uint64_t dbg_stack_address(__attribute__((unused)) struct cslice *slice) {
|
||||||
int i;
|
int i;
|
||||||
void *ptr = (void *)&i;
|
void *ptr = static_cast<void *>(&i);
|
||||||
return (uintptr_t)ptr;
|
return (uintptr_t)ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,12 +108,13 @@ struct Exception {
|
||||||
uint32_t __nac3_raise(struct Exception *e) {
|
uint32_t __nac3_raise(struct Exception *e) {
|
||||||
printf("__nac3_raise called. Exception details:\n");
|
printf("__nac3_raise called. Exception details:\n");
|
||||||
printf(" ID: %" PRIu32 "\n", e->id);
|
printf(" ID: %" PRIu32 "\n", e->id);
|
||||||
printf(" Location: %*s:%" PRIu32 ":%" PRIu32 "\n", (int)e->file.len,
|
printf(" Location: %*s:%" PRIu32 ":%" PRIu32 "\n",
|
||||||
(const char *)e->file.data, e->line, e->column);
|
static_cast<int>(e->file.len),
|
||||||
printf(" Function: %*s\n", (int)e->function.len,
|
reinterpret_cast<const char *>(e->file.data), e->line, e->column);
|
||||||
(const char *)e->function.data);
|
printf(" Function: %*s\n", static_cast<int>(e->function.len),
|
||||||
printf(" Message: \"%*s\"\n", (int)e->message.len,
|
reinterpret_cast<const char *>(e->function.data));
|
||||||
(const char *)e->message.data);
|
printf(" Message: \"%*s\"\n", static_cast<int>(e->message.len),
|
||||||
|
reinterpret_cast<const char *>(e->message.data));
|
||||||
printf(" Params: {0}=%" PRId64 ", {1}=%" PRId64 ", {2}=%" PRId64 "\n",
|
printf(" Params: {0}=%" PRId64 ", {1}=%" PRId64 ", {2}=%" PRId64 "\n",
|
||||||
e->param[0], e->param[1], e->param[2]);
|
e->param[0], e->param[1], e->param[2]);
|
||||||
exit(101);
|
exit(101);
|
||||||
|
|
Loading…
Reference in New Issue