Build everything as C++ (#1176)

This commit is contained in:
Rangi
2023-11-07 15:45:56 -05:00
committed by GitHub
parent 78d83be2b2
commit 1e70e703a7
84 changed files with 667 additions and 663 deletions

View File

@@ -19,7 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include "platform.h"
#include "platform.hpp"
#define STR(x) #x
#define XSTR(x) STR(x)
@@ -32,7 +32,7 @@ struct Attributes {
static unsigned long long randbits = 0;
static unsigned char randcount = 0;
_Noreturn static void fatal(char const *error) {
[[noreturn]] static void fatal(char const *error) {
fprintf(stderr, "FATAL: %s\n", error);
exit(1);
}
@@ -189,8 +189,8 @@ static void write_image(char const *filename, uint16_t /* const */ palettes[MIN_
uint8_t const SIZEOF_PIXEL = 4; // Each pixel is 4 bytes (RGBA @ 8 bits/component)
assert(width != 0);
assert(height != 0);
uint8_t *data = malloc(height * 8 * width * 8 * SIZEOF_PIXEL);
uint8_t **rowPtrs = malloc(height * 8 * sizeof(*rowPtrs));
uint8_t *data = (uint8_t *)malloc(height * 8 * width * 8 * SIZEOF_PIXEL);
uint8_t **rowPtrs = (uint8_t **)malloc(height * 8 * sizeof(*rowPtrs));
if (data == NULL || rowPtrs == NULL) {
fatal("Out of memory");
}
@@ -299,7 +299,7 @@ int main(int argc, char **argv) {
}
}
char *filename = malloc(nameLen + sizeof(XSTR(ULLONG_MAX) ".png"));
char *filename = (char *)malloc(nameLen + sizeof(XSTR(ULLONG_MAX) ".png"));
if (!filename) {
fatal("out of memory");
}