Fix C++ std::complex compatibility using standard C++ headers - #58
Merged
Conversation
Replace problematic C header approach with clean C++ solution: - Change #include <complex.h> to #include <complex> - Replace conj() calls with std::conj() (17 instances) Benefits: - No macro pollution (#define complex _Complex removed) - Standard C++ practice - No side effects on downstream code - Functionally identical behavior Fixes C++ template errors: 'expected unqualified-id before _Complex'
Member
|
Thanks @Emiliano-DM. For context, what happened here is that AMOS was translated from C to C++ very quickly to address the Windows build failures here scipy/scipy#20291 just before the 1.13 release. Basically, we went with the minimal diff that made the current test suite pass, with the idea that we'd come back and clean things up later. Thanks @WarrenWeckesser for reviewing. |
JaRoSchm
pushed a commit
to JaRoSchm/xsf
that referenced
this pull request
Nov 12, 2025
Replace problematic C header approach with clean C++ solution: - Change #include <complex.h> to #include <complex> - Replace conj() calls with std::conj() (17 instances) Benefits: - No macro pollution (#define complex _Complex removed) - Standard C++ practice - No side effects on downstream code - Functionally identical behavior Fixes C++ template errors: 'expected unqualified-id before _Complex'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix C++ template compilation errors when including
amos.hfrom C++ code by using standard C++ headers instead of problematic C headers.Problem
Error:
error: expected unqualified-id before '_Complex'in C++ files including amos.hRoot Cause:
#include <complex.h>defines macro#define complex _Complexstd::complex<double>becomesstd::_Complex<double>(invalid)Example failure: