Skip to content

importC: convert C complex types to use D fundamental complex and not complex library struct.#22238

Merged
thewilsonator merged 8 commits intodlang:masterfrom
Emmankoko:complex
Dec 30, 2025
Merged

importC: convert C complex types to use D fundamental complex and not complex library struct.#22238
thewilsonator merged 8 commits intodlang:masterfrom
Emmankoko:complex

Conversation

@Emmankoko
Copy link
Copy Markdown
Contributor

@Emmankoko Emmankoko commented Dec 14, 2025

I am opening this PR to reinvent the wheel for C complex for importC.
reading few comments in DMD, and conversations with @ibuclaw , DMD has the intentions of using the D fundamental complex types which is ABI compatible with the C complex types. but the implementations in several parts of the compiler contradict that. that's the main cause of issues opened on C complex and will make it impossible to compile third party libraries. with the issues opened on complex, we could provide fixes to make them work but in the end, they would be fragile since the main internal C complex machinery is broken in DMD.

This PR is supposed to lead to C complex no longer interpreted as _Complex!T.

Now, s7.c file now compiles at least. these changes have been tested with s7 which was encountering a lot of compile time errors with complex code.
link to s7 : https://ccrma.stanford.edu/software/snd/snd/s7.html
I have decided to leave the unwanted code commented out with reasons stated.
@dkorpel @thewilsonator @WalterBright @ibuclaw

I will reference a link to a test suite for s7 compiling.

@dlang-bot
Copy link
Copy Markdown
Contributor

dlang-bot commented Dec 14, 2025

Thanks for your pull request and interest in making D better, @Emmankoko! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#22238"

@dkorpel
Copy link
Copy Markdown
Contributor

dkorpel commented Dec 14, 2025

Complex numbers as a fundamental type are deprecated, lowering to a library struct is the way forward.

@Herringway
Copy link
Copy Markdown
Contributor

Complex numbers as a fundamental type are deprecated, lowering to a library struct is the way forward.

The "way forward" is the status quo, and it appears to be broken.

#22218 (comment)

@Emmankoko
Copy link
Copy Markdown
Contributor Author

an example comment I found in typesem, it has excluded C code in fundamental complex duplication.

https://github.com/dlang/dmd/blob/master/compiler/src/dmd/typesem.d#L1433

@Emmankoko Emmankoko force-pushed the complex branch 2 times, most recently from cab4f9b to 9adad75 Compare December 18, 2025 12:15
@Emmankoko Emmankoko marked this pull request as ready for review December 23, 2025 22:32
Comment thread compiler/src/dmd/expressionsem.d
using the fundamental complex interferes with this a little when
compiling s7 library.this fixes it.
@thewilsonator thewilsonator merged commit 3e076a9 into dlang:master Dec 30, 2025
42 checks passed
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.

5 participants