importC: convert C complex types to use D fundamental complex and not complex library struct.#22238
Conversation
|
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 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 referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
|
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. |
|
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 |
cab4f9b to
9adad75
Compare
since c_long_double is a (1o bytes) known mismatch, complex real similarly falls in that category since it is simple two long doubles
using the fundamental complex interferes with this a little when compiling s7 library.this fixes it.
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.