Shirakumo / cl-mixed

A simple audio mixing and processing library based on libmixed.
https://shirakumo.github.io/cl-mixed/
zlib License
22 stars 7 forks source link

Using constants inside #. - needs eval-when (compile #11

Closed Yehouda closed 1 year ago

Yehouda commented 1 year ago

https://github.com/Shirakumo/cl-mixed/blob/4aaff134d3902d93a2a8605c10de4bcfc62d7afa/extensions/winmm-cffi.lisp#L50

WAVE-FORMAT-PCM and WAVE-FORMAT-IEEE-FLOAT are used in #. (i.e. at read time) in winmm-dffi.lisp, and are defined using defconstant earlier in the file. That shouldn't work when compiling the file, because defconstant make the compiler recognize, but not the reader. It can work if you load the source file first or evaluate this form first, or in a buggy compiler that make the definitions of defconstant visible to the reader too at compile-time.

The right way to fix that is to add eval-when (compile load eval) around the constants:

(eval-when (compile load eval)
  (defconstant WAVE-FORMAT-PCM #x1)
  (defconstant WAVE-FORMAT-IEEE-FLOAT #x3)
  (defconstant WAVE-MAPPER #xFFFFFFFF)
  (defconstant INFINITE (1- (expt 2 32)))
  )
Shinmera commented 1 year ago

A compiler that does that isn't buggy, it's allowed but not guaranteed by the standard.

Anyway, the winmm backend is broken even besides this so it doesn't really matter.

Yehouda commented 1 year ago

It does matter, because when you just type (ql:quickload "harmony") you get an error, and not all users find it easy to figure out what is wrong.

If the winmm is too broken to be fixed, then it is probably better to take it out of the system.