The function `psf_round` is only defined if you use Microsoft Visual C++ compiler
This function will not be defined if you use a compiler like gcc or clang.
Here is me building the project.
```sh
mkdir build
cd build
cmake ..
```
```sh
➜ build git:(main) make -j8
[ 0%] Built target pvxio2
[ 0%] Built target asciiget
[ 0%] Built target aaio
[ 0%] Built target convert_to_midi
[ 1%] Built target sfsys
[ 2%] Built target dshift
[ 2%] Built target tsconvert
[ 5%] Built target cdp2k
[ 5%] Building C object dev/externals/portsf/CMakeFiles/portsf.dir/portsf.c.o
[ 5%] Built target rmresp
[ 6%] Built target dirsf
[ 6%] Built target sfprops
[ 6%] Built target cdparams
[ 7%] Built target tapdelay
[ 8%] Built target cdparams_other
[ 8%] Built target cdparse
[ 9%] Built target blur
[ 11%] Built target envel
[ 13%] Built target extend
[ 14%] Built target combine
[ 14%] Built target sfedit
[ 18%] Built target distort
[ 19%] Built target filter
/home/enkvadrat/bin/cdp/dev/externals/portsf/portsf.c: In function ‘psf_sndWriteFloatFrames’:
/home/enkvadrat/bin/cdp/dev/externals/portsf/portsf.c:1675:45: error: implicit declaration of function ‘psf_round’ [-Wimplicit-function-declaration]
1675 | ssamp = (short) psf_round(fsamp * 32766.0 + 2.0 * trirand());
| ^~~~~~~~~
[ 20%] Built target grain
[ 21%] Built target hilite
[ 23%] Built target formants
[ 23%] Built target hfperm
[ 23%] Built target focus
[ 24%] Built target housekeep
[ 25%] Built target brkdur
make[2]: *** [dev/externals/portsf/CMakeFiles/portsf.dir/build.make:79: dev/externals/portsf/CMakeFiles/portsf.dir/portsf.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:8814: dev/externals/portsf/CMakeFiles/portsf.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 25%] Built target histconv
[ 25%] Built target fixgobo
[ 25%] Built target gobosee
[ 26%] Built target gobo
[ 26%] Built target diskspace
[ 26%] Built target listdate
[ 27%] Built target logdate
make: *** [Makefile:156: all] Error 2
```
I am not sure if we want to maintain the old one but surely we now have some
function in the c standard library?
https://stackoverflow.com/questions/32746523/ieee-754-compliant-round-half-to-even
```patch
diff --git a/dev/externals/portsf/portsf.c b/dev/externals/portsf/portsf.c
index dea63d6..40bc809 100755
--- a/dev/externals/portsf/portsf.c
+++ b/dev/externals/portsf/portsf.c
@@ -487,36 +487,10 @@ static int psf_wordsize(psf_stype type)
}
-
-#ifdef _MSC_VER
-# if(_MSC_VER <= 1200)
-/* fast convergent rounding */
-__inline int psf_round(double fval)
-{
- int result;
- _asm{
- fld fval
- fistp result
- mov eax,result
- }
- return result;
+int psf_round(double val) {
+ return (int)rint(val);
}
-# else
-/* slow convergent rounding ! */
-/* TODO: implement IEEE round-to-even */
-int psf_round(double val);
-# endif
-int psf_round(double val)
-{
- long k;
- k = (long)(fabs(val)+0.5);
- if(val < 0.0)
- k = -k;
- return (int) k;
-}
-#endif
-
#ifndef WIN32
int stricmp(const char *a, const char *b)
{
```
By giving some implementation of the function I can build the project.
This should work but there is a risk that functionality will be changed. `rint` should match the behavior of the "fast convergent rounding" code but that has probably not been in use for a very long time (20+ years).
关闭于 2026-01-08 3 条评论