Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ jobs:
flags: '-std=gnu99 -w'
- name: GCC 2.95
compiler: g++-2.95
flags: '-fpermissive -w'
flags: '-w'
name: Build (${{ matrix.name }})
runs-on: ubuntu-latest
steps:
Expand All @@ -408,3 +408,16 @@ jobs:
run: |
sudo mv butterscotch ~/woody
sudo chroot ~/woody /bin/sh --login -c 'make -C /butterscotch NO_COLOR=1 VERBOSE=1 CC="${{ matrix.compiler }} ${{ matrix.flags }}" DESKTOP_BACKEND=sdl1 AUDIO_BACKEND=none SDL1_LIBS='-lSDL' DISABLE_MMD=1'

build-cxx:
name: Build as C++
runs-on: ubuntu-24.04
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libglfw3-dev

- name: Build
run: make CC='g++ -std=gnu++98 -Wall -Wvla -Werror' NO_COLOR=1 VERBOSE=1
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(butterscotch C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
add_compile_options(-Wall -Wextra -Werror)
add_compile_options(-Wall -Wextra -Wvla -Werror)

set(PLATFORM "desktop" CACHE STRING "Platform backend")
set(DESKTOP_BACKEND "" CACHE STRING "Desktop platform backend")
Expand Down
8 changes: 4 additions & 4 deletions src/audio/miniaudio/ma_audio_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,11 @@ static void maGroupLoad(AudioSystem* audio, int32_t groupIndex) {
char* buf;
if (audioGroupEntry->path == nullptr) {
int sz = snprintf(nullptr, 0, "audiogroup%d.dat", groupIndex);
buf = safeMalloc(sz + 1);
buf = (char *)safeMalloc(sz + 1);
snprintf(buf, sz + 1, "audiogroup%d.dat", groupIndex);
} else {
size_t length = strlen(audioGroupEntry->path);
buf = safeMalloc(length + 1);
buf = (char *)safeMalloc(length + 1);
memcpy(buf, audioGroupEntry->path, length);
buf[length] = '\0';
}
Expand All @@ -707,7 +707,7 @@ static void maGroupLoad(AudioSystem* audio, int32_t groupIndex) {
if (!fileSystem->vtable->fileExists(fileSystem, buf)) {
fprintf(stderr, "Audio: Wanted to load Audio Group %d, but Audio Group %d does not exist in the file system!\n", groupIndex, groupIndex);
free(buf);
DataWin* dw = safeCalloc(1, sizeof(DataWin));
DataWin* dw = (DataWin *)safeCalloc(1, sizeof(DataWin));
arrput(audio->audioGroups, dw);
return;
}
Expand Down Expand Up @@ -800,7 +800,7 @@ static AudioSystemVtable maAudioSystemVtable;
// ===[ Lifecycle ]===

MaAudioSystem* MaAudioSystem_create(DataWin* dataWin) {
MaAudioSystem* ma = safeCalloc(1, sizeof(MaAudioSystem));
MaAudioSystem* ma = (MaAudioSystem *)safeCalloc(1, sizeof(MaAudioSystem));
ma->base.dw = dataWin;
maAudioSystemVtable.init = maInit;
maAudioSystemVtable.destroy = maDestroy;
Expand Down
9 changes: 5 additions & 4 deletions src/audio/openal/al_audio_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static int32_t maPlaySound(AudioSystem* audio, int32_t soundIndex, int32_t prior
slot->streamSampleRate = (int) info.sample_rate;
slot->streamFormat = (info.channels == 2) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16;
slot->streamLengthSeconds = stb_vorbis_stream_length_in_seconds(v);
slot->decodeScratch = safeMalloc(AL_STREAM_BUFFER_SAMPLES * info.channels * sizeof(int16_t));
slot->decodeScratch = (int16_t *)safeMalloc(AL_STREAM_BUFFER_SAMPLES * info.channels * sizeof(int16_t));

alGenSources(1, &slot->alSource);
alGenBuffers(AL_STREAM_BUFFER_COUNT, slot->streamBuffers);
Expand Down Expand Up @@ -804,8 +804,8 @@ static void maSetChannelCount(MAYBE_UNUSED AudioSystem* audio, MAYBE_UNUSED int3
static void maGroupLoad(AudioSystem* audio, int32_t groupIndex) {
if (groupIndex > 0) {
int sz = snprintf(nullptr, 0, "audiogroup%d.dat", groupIndex);
char buf[sz + 1];
snprintf(buf, sizeof(buf), "audiogroup%d.dat", groupIndex);
char *buf = (char *)safeMalloc(sz + 1);
snprintf(buf, sz + 1, "audiogroup%d.dat", groupIndex);

// The original runner does not care if the file doesn't exist (this may happen if someone uses "audio_group_load" on a non-existent group)
FileSystem* fileSystem = ((AlAudioSystem*)audio)->fileSystem;
Expand All @@ -819,6 +819,7 @@ static void maGroupLoad(AudioSystem* audio, int32_t groupIndex) {
options.parseAudo = true;
DataWin *audioGroup = DataWin_parse(((AlAudioSystem*)audio)->fileSystem->vtable->resolvePath(((AlAudioSystem*)audio)->fileSystem, buf), options);
arrput(audio->audioGroups, audioGroup);
free(buf);
}
}

Expand Down Expand Up @@ -893,7 +894,7 @@ static AudioSystemVtable AlAudioSystemVtable;
// ===[ Lifecycle ]===

AlAudioSystem* AlAudioSystem_create(void) {
AlAudioSystem* ma = safeCalloc(1, sizeof(AlAudioSystem));
AlAudioSystem* ma = (AlAudioSystem *)safeCalloc(1, sizeof(AlAudioSystem));
AlAudioSystemVtable.init = maInit;
AlAudioSystemVtable.destroy = maDestroy;
AlAudioSystemVtable.update = maUpdate;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/openal/wave.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ WAVFile WAV_ParseFileData(uint8_t const* data) {
data_ptr += 4;

// memcpy so we don't byteswap the original data more than once
file.data = safeMalloc(file.header.data_size);
file.data = (uint8_t *)safeMalloc(file.header.data_size);
memcpy(file.data, data_ptr, file.header.data_size);
file.data_length = file.header.data_size;

Expand All @@ -89,4 +89,4 @@ WAVFile WAV_ParseFileData(uint8_t const* data) {
}

return file;
}
}
2 changes: 1 addition & 1 deletion src/binary_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void BinaryReader_readBytes(BinaryReader* reader, void* dest, size_t count) {
}

uint8_t* BinaryReader_readBytesAt(BinaryReader* reader, size_t offset, size_t count) {
uint8_t* buf = safeMalloc(count);
uint8_t* buf = (uint8_t *)safeMalloc(count);

if (reader->buffer != nullptr) {
if (offset < reader->bufferBase || offset + count > reader->bufferBase + reader->bufferSize) {
Expand Down
28 changes: 16 additions & 12 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@
#define IS_BIG_ENDIAN
#endif

#if defined(__has_c_attribute)
#if __has_c_attribute(maybe_unused)
#define MAYBE_UNUSED [[maybe_unused]]
#endif
#endif

#ifndef MAYBE_UNUSED
#if defined(__GNUC__) || defined(__clang__)
#define MAYBE_UNUSED __attribute__((unused))
#else
#define MAYBE_UNUSED
#endif
#if defined(__cplusplus) && __cplusplus >= 201703L
#define MAYBE_UNUSED [[maybe_unused]]
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
#define MAYBE_UNUSED [[maybe_unused]]
#elif defined(__GNUC__) || defined(__clang__)
#define MAYBE_UNUSED __attribute__((unused))
#else
#define MAYBE_UNUSED
#endif

#if (defined(__GNUC__) && (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))) || defined(__TINYC__)
Expand All @@ -42,6 +38,14 @@
#define ALIGN(x)
#endif

#if defined(__GNUC__) || defined(__TINYC__)
#define NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER) && _MSC_VER >= 1400 // VS2005 or later
#define NOINLINE __declspec(noinline)
#else
#define NOINLINE
#endif

#if defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(__i386__)
#define YIELD() __asm__ volatile("rep; nop" : : : "memory")
Expand Down
Loading
Loading