Closed xnorpx closed 1 year ago
Tested on Linux and Windows with Opus CMake build.
cmake .. -DOPUS_X86_PRESUME_AVX=OFF -DOPUS_FLOAT_APPROX=OFF -DOPUS_FAST_MATH=OFF -DOPUS_BUILD_TESTING=ON
opus\lpcnet\src\vec.h(62,21): error C2059: syntax error: '
C2059 is raised when a preprocessor symbol name is re-used as an identifier. In the following example, the compiler sees DIGITS.ONE as the number 1, which is not valid as an enum element name:
cmake .. -DOPUS_X86_PRESUME_AVX=OFF -DOPUS_FLOAT_APPROX=ON -DOPUS_FAST_MATH=OFF -DOPUS_BUILD_TESTING=ON
\opus\celt\mathops.h(148,26): error C2084: function 'float celt_exp2(float)' already has a body \opus\build\opus.vcxproj] \opus\lpcnet\src\vec.h(62): message : see previous definition of 'celt_exp2' C:\git\xnorpx\opus\build\opus.vcxproj]
cmake .. -DOPUS_X86_PRESUME_AVX=OFF -DOPUS_FLOAT_APPROX=OFF -DOPUS_FAST_MATH=OFF -DOPUS_BUILD_TESTING=ON
Works
merged
This PR includes 3 changes to allow for Lpcnet Opus WIP work on Windows.
Using the same function name celt_exp2 with what is already in the Opus repo seems to throw the compiler/linker off and we get a cryptic parameter list error message that makes no sense but renaming the function solves this.
Use pragma message as preprocessor directive warning is not supported on MSVC
Include a missing header for MSVC due to use of floor in avx code.
Note that this needs to be refactored for runtime detection of AVX on MSVC.
When compiling a C file with AVX instructions and the /AVX2 compiler flag on MSVC, and including the math.h header, there is a possibility of AVX2-specific math objects being brought in. However, due to the linker's random selection of objects depending on their order, AVX2 instructions may be inadvertently used in code that is not intended to have them. This can lead to crashes on older machines that do not support AVX2 instructions.