From 7f456cff6924cd71bae95279559c7694ca7e8e14 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Sun, 1 May 2022 08:41:41 +0100 Subject: [PATCH] Make cabi C++ compatible Casting the result of these calls to malloc should be all that is required to make cabi compilable as C++. Without these casts cabi won't compile as C++ because in C++ `void *` is not implicitly convertible to other data types. LodePNG already has C++ compatibility. --- extras/cabi/cabi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/cabi/cabi.c b/extras/cabi/cabi.c index 31f1bca..4dea3c3 100644 --- a/extras/cabi/cabi.c +++ b/extras/cabi/cabi.c @@ -342,8 +342,8 @@ int main(int argc, char **argv) rawlen = w * (h+7) / 8; - bmp0 = malloc(rawlen); memset(bmp0, 0, rawlen); - bmp1 = malloc(rawlen); memset(bmp1, 0, rawlen); + bmp0 = (unsigned char *)malloc(rawlen); memset(bmp0, 0, rawlen); + bmp1 = (unsigned char *)malloc(rawlen); memset(bmp1, 0, rawlen); printf("// %s width: %u height: %u\n", argv[1], w, h);