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

@@ -13,11 +13,11 @@
#include <stdlib.h>
#include <string.h>
#include "extern/getopt.h"
#include "extern/getopt.hpp"
#include "helpers.h"
#include "platform.h"
#include "version.h"
#include "helpers.hpp"
#include "platform.hpp"
#include "version.hpp"
#define UNSPECIFIED 0x200 // Should not be in byte range
@@ -230,7 +230,7 @@ static enum MbcType parseMBC(char const *name)
return MBC_BAD;
if (mbc > 0xFF)
return MBC_BAD_RANGE;
return mbc;
return (enum MbcType)mbc;
} else {
// Begin by reading the MBC type:
@@ -570,7 +570,7 @@ do { \
if (*ptr)
return MBC_BAD;
return mbc;
return (enum MbcType)mbc;
}
}
@@ -1000,7 +1000,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
} else if (rom0Len == BANK_SIZE) {
// Copy ROMX when reading a pipe, and we're not at EOF yet
for (;;) {
romx = realloc(romx, nbBanks * BANK_SIZE);
romx = (uint8_t *)realloc(romx, nbBanks * BANK_SIZE);
if (!romx) {
report("FATAL: Failed to realloc ROMX buffer: %s\n",
strerror(errno));
@@ -1094,11 +1094,13 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
if (fixSpec & TRASH_GLOBAL_SUM)
globalSum = ~globalSum;
uint8_t bytes[2] = {globalSum >> 8, globalSum & 0xFF};
uint8_t bytes[2] = {(uint8_t)(globalSum >> 8), (uint8_t)(globalSum & 0xFF)};
overwriteBytes(rom0, 0x14E, bytes, sizeof(bytes), "global checksum");
}
ssize_t writeLen;
// In case the output depends on the input, reset to the beginning of the file, and only
// write the header
if (input == output) {
@@ -1111,7 +1113,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
if (padValue == UNSPECIFIED)
rom0Len = headerSize;
}
ssize_t writeLen = writeBytes(output, rom0, rom0Len);
writeLen = writeBytes(output, rom0, rom0Len);
if (writeLen == -1) {
report("FATAL: Failed to write \"%s\"'s ROM0: %s\n", name, strerror(errno));