shorepine / amy

AMY - the Additive Music synthesizer librarY

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AMY_IS_SET usage causes compile to fail

octetta opened this issue · comments

AMY_IS_SET uses isnan, which requires a floating point value (at least on Ubuntu 20.04 with gcc).
algo_source seems to be an integer, causing a failure.

I suspect this is because of the change of using NAN as a flag instead of -1?

Will tinker with this later, but wanted to point it out.

src/algorithms.c: In function ‘algo_note_off’:
src/algorithms.c:143:12: error: non-floating-point argument in call to function ‘__builtin_isnan’
  143 |         if(AMY_IS_SET(synth[osc].algo_source[i])) {
      |            ^~~~~~~~~~
src/algorithms.c: In function ‘algo_note_on’:
src/algorithms.c:232:8: error: non-floating-point argument in call to function ‘__builtin_isnan’
  232 |     if(AMY_IS_SET(synth[osc].patch)) {
      |        ^~~~~~~~~~
src/algorithms.c:236:12: error: non-floating-point argument in call to function ‘__builtin_isnan’
  236 |         if(AMY_IS_SET(synth[osc].algo_source[i])) {
      |            ^~~~~~~~~~
src/algorithms.c: In function ‘render_algo’:
src/algorithms.c:264:12: error: non-floating-point argument in call to function ‘__builtin_isnan’
  264 |         if(AMY_IS_SET(synth[osc].algo_source[op]) && synth[synth[osc].algo_source[op]].status == IS_ALGO_SOURCE) {
      |            ^~~~~~~~~~
make: *** [Makefile:39: src/algorithms.o] Error 1

Whoa, that is weird. algo_source is a uint16, and AMY_IS_SET should know that before trying to isnan it. This seems to be some sort of compiler issue. I will dig in asap!

I'm not following the _Generic stuff at all, but it looks intriguing.

FYI, I'm using gcc 12.2.0-14 if that's useful to know.

Hm yeah, I see it on my Ubuntu20. I think we're running into this
https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/c11-generic/

Yeah, it was that. Weird! I committed a fix and it compiles for me

Nice. A pull and a make solves the problems (along with hundreds of warning in fm.h that I didn't report). Thanks!