From 9f565412ca6596b0cd867a225b3d505cd378f2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Wed, 18 May 2022 23:40:15 -0600 Subject: [PATCH] Use int32_t style for ints --- src/libasr/codegen/asr_to_c.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libasr/codegen/asr_to_c.cpp b/src/libasr/codegen/asr_to_c.cpp index a25939b41a..f761bc8b21 100644 --- a/src/libasr/codegen/asr_to_c.cpp +++ b/src/libasr/codegen/asr_to_c.cpp @@ -82,8 +82,16 @@ class ASRToCVisitor : public BaseCCPPVisitor if (ASRUtils::is_integer(*v.m_type)) { ASR::Integer_t *t = ASR::down_cast(v.m_type); std::string dims = convert_dims_c(t->n_dims, t->m_dims); - std::string type_name = "int"; - if (t->m_kind == 8) type_name = "long long"; + std::string type_name; + if (t->m_kind == 1) { + type_name = "int8_t"; + } else if (t->m_kind == 2) { + type_name = "int16_t"; + } else if (t->m_kind == 4) { + type_name = "int32_t"; + } else if (t->m_kind == 8) { + type_name = "int64_t"; + } sub = format_type_c(dims, type_name, v.m_name, use_ref, dummy); } else if (ASRUtils::is_real(*v.m_type)) { ASR::Real_t *t = ASR::down_cast(v.m_type); @@ -100,7 +108,7 @@ class ASRToCVisitor : public BaseCCPPVisitor } else if (ASRUtils::is_logical(*v.m_type)) { ASR::Logical_t *t = ASR::down_cast(v.m_type); std::string dims = convert_dims_c(t->n_dims, t->m_dims); - sub = format_type_c(dims, "bool", v.m_name, use_ref, dummy); + sub = format_type_c(dims, "int8_t", v.m_name, use_ref, dummy); } else if (ASRUtils::is_character(*v.m_type)) { // TODO } else if (ASR::is_a(*v.m_type)) {