aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-01-28 23:35:01 +0000
committergingerBill <bill@gingerbill.org>2024-01-28 23:35:01 +0000
commit3c47503780bd99b547777b727baf502504244bbb (patch)
tree45dc4b5cec3fd5f4c79439ba3838a547af1c8b7f
parent6da82e038d7471458ae46146218a7bac47ab82ca (diff)
Improve foreign variable fuzzy type checking
-rw-r--r--base/runtime/os_specific_bsd.odin3
-rw-r--r--base/runtime/os_specific_darwin.odin1
-rw-r--r--src/check_decl.cpp4
-rw-r--r--src/check_stmt.cpp2
4 files changed, 6 insertions, 4 deletions
diff --git a/base/runtime/os_specific_bsd.odin b/base/runtime/os_specific_bsd.odin
index 93ed9b4e6..7f23b625e 100644
--- a/base/runtime/os_specific_bsd.odin
+++ b/base/runtime/os_specific_bsd.odin
@@ -4,9 +4,10 @@ package runtime
foreign import libc "system:c"
+@(default_calling_convention="c")
foreign libc {
@(link_name="write")
- _unix_write :: proc(fd: uintptr, buf: rawptr, size: int) -> int ---
+ _unix_write :: proc(fd: i32, buf: rawptr, size: int) -> int ---
__error :: proc() -> ^i32 ---
}
diff --git a/base/runtime/os_specific_darwin.odin b/base/runtime/os_specific_darwin.odin
index 5630c733c..0cb46024c 100644
--- a/base/runtime/os_specific_darwin.odin
+++ b/base/runtime/os_specific_darwin.odin
@@ -4,6 +4,7 @@ package runtime
foreign import libc "system:System.framework"
+@(default_calling_convention="c")
foreign libc {
@(link_name="__stderrp")
_stderr: rawptr
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index ed3a109c2..3ccf1b97a 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -1143,7 +1143,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
"\tat %s",
LIT(name), token_pos_to_string(pos));
}
- } else if (!are_types_identical(this_type, other_type)) {
+ } else if (!signature_parameter_similar_enough(this_type, other_type)) {
error(d->proc_lit,
"Foreign entity '%.*s' previously declared elsewhere with a different type\n"
"\tat %s",
@@ -1284,7 +1284,7 @@ gb_internal void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast
TokenPos pos = f->token.pos;
Type *this_type = base_type(e->type);
Type *other_type = base_type(f->type);
- if (!are_types_identical(this_type, other_type)) {
+ if (!signature_parameter_similar_enough(this_type, other_type)) {
error(e->token,
"Foreign entity '%.*s' previously declared elsewhere with a different type\n"
"\tat %s",
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index d56e5e212..6897701d6 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -1934,7 +1934,7 @@ gb_internal void check_value_decl_stmt(CheckerContext *ctx, Ast *node, u32 mod_f
TokenPos pos = f->token.pos;
Type *this_type = base_type(e->type);
Type *other_type = base_type(f->type);
- if (!are_types_identical(this_type, other_type)) {
+ if (!signature_parameter_similar_enough(this_type, other_type)) {
error(e->token,
"Foreign entity '%.*s' previously declared elsewhere with a different type\n"
"\tat %s",