Thanks to visit codestin.com
Credit goes to github.com

Skip to content

C: Fix complex types #2193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libasr/codegen/asr_to_c_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,13 @@ R"(#include <stdio.h>
if (gen_stdcomplex) {
sub = "std::complex<float> ";
} else {
sub = "float complex ";
sub = "float_complex_t ";
}
} else {
if (gen_stdcomplex) {
sub = "std::complex<double> ";
} else {
sub = "double complex ";
sub = "double_complex_t ";
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libasr/codegen/c_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ namespace CUtils {
case ASR::ttypeType::Complex: {
if( kind == 4 ) {
if( is_c ) {
type_src = "float complex";
type_src = "float_complex_t";
} else {
type_src = "std::complex<float>";
}
} else if( kind == 8 ) {
if( is_c ) {
type_src = "double complex";
type_src = "double_complex_t";
} else {
type_src = "std::complex<double>";
}
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/c-expr7-bb2692a.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "c-expr7-bb2692a.stdout",
"stdout_hash": "11026dff0f543f773698075edb3d690f8a475e8639124f1e1dcaef6a",
"stdout_hash": "49af46a64f7f11d442e2216c1bb51d307305cc70980caa7952cc85d1",
"stderr": "c-expr7-bb2692a.stderr",
"stderr_hash": "6e9790ac88db1a9ead8f64a91ba8a6605de67167037908a74b77be0c",
"returncode": 0
Expand Down
4 changes: 2 additions & 2 deletions tests/reference/c-expr7-bb2692a.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ double __lpython_overloaded_0__pow(int32_t x, int32_t y)
return _lpython_return_variable;
}

float _lfortran_caimag(float complex x);
float _lfortran_caimag(float_complex_t x);

double _lfortran_zaimag(double complex x);
double _lfortran_zaimag(double_complex_t x);

void test_pow()
{
Expand Down