Skip to content

Fix missing includes: <cstring> and <cassert> during build - #84

Open
dahbiz wants to merge 1 commit into
fastlib:mainfrom
dahbiz:patches
Open

Fix missing includes: <cstring> and <cassert> during build#84
dahbiz wants to merge 1 commit into
fastlib:mainfrom
dahbiz:patches

Conversation

@dahbiz

@dahbiz dahbiz commented Nov 4, 2025

Copy link
Copy Markdown

No description provided.

felixdollack referenced this pull request in felixdollack/fCWT May 15, 2026
…#84)

- Fix delete→free in Morlet::getWavelet() for malloc-allocated memory
- Fix memory leak: free lastscalemem with _aligned_free/_aligned_malloc
  on Windows, free/aligned_alloc on POSIX
- Add missing <cassert> include (issue #84)
- Also fix indentation in convolve() else branch

Co-Authored-By: Oz <oz-agent@warp.dev>
felixdollack added a commit to felixdollack/fCWT_org that referenced this pull request Aug 28, 2026
The extension does not compile on arm64 macOS. Three things break:

1. `-mavx` is rejected by clang for arm64-apple-darwin targets. The AVX
   code paths are already guarded by `#if defined(__AVX__)` (fcwt.h) and
   `#ifdef AVX` (fcwt.cpp), so omitting the flag selects the scalar path.

2. `-lomp` resolves to the vendored libs/libomp.a, which is x86_64-only.
   The fftw3f archives are universal (x86_64 + arm64); only the OpenMP
   runtime is missing. Building with -DSINGLE_THREAD takes the
   non-OpenMP path instead. Note that nthreads is then ignored.

3. Without omp.h, fcwt.cpp has no declaration for assert() or for
   memset()/memcpy(); they had only ever arrived transitively.

The x86_64 macOS and Linux paths are left unchanged.

For (3), <cassert> and <cstring> are added to fcwt.h. This is the same
fix as PR fastlib#84, and it also covers the MSVC failure in issue fastlib#79
(error C3861: 'assert': identifier not found, at the five assert sites
in fcwt.cpp) and the MinGW report in issue fastlib#81 -- neither of which is
specific to Apple Silicon. memset/memcpy are used at seven sites in
fcwt.cpp with no <cstring> include anywhere in the tree.

Also add libs/ to include_dirs so that the `#include "fftw3.h"` in
fcwt.h resolves when building from a repository checkout. PR fastlib#32 landed
the matching library_dirs entry but not this one; the 0.1.18 sdist on
PyPI already carries the include path.

Verified on Darwin 25.3.0 / arm64 with Python 3.11.14: the extension
builds, `fcwt.cwt()` of a 50 Hz tone (fs=1000, f0=1, f1=100, fn=64,
log scaling) peaks in the expected bin, and tests/test_fcwt.py gives
7 passed, 1 failed. The remaining failure, test_plan, is unrelated to
this change: only the std::string overload of
create_FFT_optimization_plan is present in the checked-in SWIG
wrapper, so the (int, int) call in the test cannot dispatch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant