thinkingsand / rat

rat
The Unlicense
11 stars 2 forks source link

Compile error #16

Open RGBCube opened 8 months ago

RGBCube commented 8 months ago
rat> building '/nix/store/0is25j3abjgfc1wkf1h2p08gb4j1pl71-rat-2.0.1.drv'
rat> Running phase: unpackPhase
rat> unpacking source archive /nix/store/hb6i0r4adglv8vycgwdzk5nr7xq6m77p-source
rat> source root is source
rat> Running phase: patchPhase
rat> Running phase: updateAutotoolsGnuConfigScriptsPhase
rat> Running phase: configurePhase
rat> no configure script, doing nothing
rat> Running phase: buildPhase
rat> xxd -i audio/loop.wav > audio/linux_loop.h
rat> mkdir bin
rat> gcc -DAUDIO_EN rat.c audio/linux_audio.c -o bin/rat -lm -lpthread
rat> rat.c: In function 'main':
rat> rat.c:143:9: error: format not a string literal and no format arguments [-Werror=format-security]
rat>   143 |         printf(frames[i]);
rat>       |         ^~~~~~
rat> cc1: some warnings being treated as errors
rat> audio/linux_audio.c: In function 'linux_audioplay':
rat> audio/linux_audio.c:31:9: warning: 'return' with no value, in function returning non-void
rat>    31 |         return;
rat>       |         ^~~~~~
rat> audio/linux_audio.c:19:7: note: declared here
rat>    19 | void *linux_audioplay()
rat>       |       ^~~~~~~~~~~~~~~
rat> In file included from audio/linux_audio.c:2:
rat> audio/miniaudio.h: In function 'ma_device_stop__alsa':
rat> audio/miniaudio.h:28071:9: warning: ignoring return value of 'read' declared with attribute 'warn_unused_result' [-Wunused-result]
rat> 28071 |         read(((struct pollfd*)pDevice->alsa.pPollDescriptorsCapture)[0].fd, &t, sizeof(t));
rat>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rat> audio/miniaudio.h:28092:9: warning: ignoring return value of 'read' declared with attribute 'warn_unused_result' [-Wunused-result]

On the latest commit, my cc is:

clang version 16.0.6
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/s0rk29zc6n3x6xmpb39rypac36k2gpbj-clang-16.0.6/bin
thinkingsand commented 8 months ago

Hi. The code seems to compile fine for me on Debian 12, on a fresh install with build-essential and xxd. I noticed you're using Nix, that's not something I maintain the package for. I'd recommend getting in touch with whoever does, this seems to be an issue with the packaging.

thinkingsand commented 8 months ago

Turns out it was just the Nix package being configured to treat string warnings as hard errors, this should be fixed now.

RGBCube commented 8 months ago

Works! Although I can't hear the audio for some reason. (Yes I am doing make linux_audio)

thinkingsand commented 8 months ago

I've tested the audio code in the past across Debian, Fedora and Arch, and across both PulseAudio and Pipewire. Without more info I can't really troubleshoot things beyond that. Let me know if you can reproduce on a mainstream distro and I'll take a look.

RGBCube commented 8 months ago

Alright, I'll try it soon on another machine. Will let you know if it doesn't work