-
Notifications
You must be signed in to change notification settings - Fork 173
C: Support header files in ccall
#1731
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| #ifndef BINDC_05BH | ||
| #define BINDC_05BH | ||
|
|
||
| void* trunc_custom(void** value); | ||
| void print_value(float* value); | ||
|
|
||
| #endif // BINDC_05BH | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| #ifndef BINDC_06BH | ||
| #define BINDC_06BH | ||
|
|
||
| #include <inttypes.h> | ||
|
|
||
| int32_t compare_array_element(int32_t value1, double value2, int32_t code); | ||
|
|
||
| #endif // BINDC_06BH |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,7 +279,7 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor> | |
| std::string dims; | ||
| use_ref = use_ref && !is_array; | ||
| if (ASRUtils::is_integer(*v_m_type)) { | ||
| headers.insert("inttypes"); | ||
| headers.insert("inttypes.h"); | ||
| ASR::Integer_t *t = ASR::down_cast<ASR::Integer_t>(v_m_type); | ||
| std::string type_name = "int" + std::to_string(t->m_kind * 8) + "_t"; | ||
| if( is_array ) { | ||
|
|
@@ -354,7 +354,7 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor> | |
| sub = format_type_c(dims, type_name, v_m_name, use_ref, dummy); | ||
| } | ||
| } else if (ASRUtils::is_complex(*v_m_type)) { | ||
| headers.insert("complex"); | ||
| headers.insert("complex.h"); | ||
| ASR::Complex_t *t = ASR::down_cast<ASR::Complex_t>(v_m_type); | ||
| std::string type_name = "float complex"; | ||
| if (t->m_kind == 8) type_name = "double complex"; | ||
|
|
@@ -713,8 +713,11 @@ R"( | |
| } | ||
| } | ||
| std::string to_include = ""; | ||
| for (auto s: headers) { | ||
| to_include += "#include <" + s + ".h>\n"; | ||
| for (auto &s: headers) { | ||
| to_include += "#include <" + s + ">\n"; | ||
| } | ||
| for (auto &s: user_headers) { | ||
| to_include += "#include \"" + s + "\"\n"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now let's use We probably should distinguish between a header file that should be referenced with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, thanks! |
||
| } | ||
| if( c_ds_api->get_func_decls().size() > 0 ) { | ||
| array_types_decls += "\n" + c_ds_api->get_func_decls() + "\n"; | ||
|
|
@@ -1006,7 +1009,7 @@ R"( | |
| } | ||
|
|
||
| void visit_ComplexConstant(const ASR::ComplexConstant_t &x) { | ||
| headers.insert("complex"); | ||
| headers.insert("complex.h"); | ||
| std::string re = std::to_string(x.m_re); | ||
| std::string im = std::to_string(x.m_im); | ||
| src = "CMPLX(" + re + ", " + im + ")"; | ||
|
|
@@ -1203,7 +1206,7 @@ R"( | |
|
|
||
| void visit_ArrayConstant(const ASR::ArrayConstant_t& x) { | ||
| // TODO: Support and test for multi-dimensional array constants | ||
| headers.insert("stdarg"); | ||
| headers.insert("stdarg.h"); | ||
| std::string array_const = ""; | ||
| for( size_t i = 0; i < x.n_args; i++ ) { | ||
| visit_expr(*x.m_args[i]); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.