From c2dc9927ef38b429ebcc407c1d31522e914c8719 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 18 Oct 2026 22:44:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(func):=20extern=20def=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=A3=B8=E5=90=8D=E5=B9=B6=E7=99=BB=E8=AE=B0=E8=B7=A8=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit extern def longjmp/_setjmp/GetEnvironmentVariableA 等不再加 SHA1 前缀;声明加入 _export_funcs 与 _export_extern_funcs,链接可解析到 C/系统符号。 --- lib/core/Handles/HandlesFunctions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/core/Handles/HandlesFunctions.py b/lib/core/Handles/HandlesFunctions.py index b72ec90..d726103 100644 --- a/lib/core/Handles/HandlesFunctions.py +++ b/lib/core/Handles/HandlesFunctions.py @@ -1194,9 +1194,13 @@ class FunctionHandle(BaseHandle): self.Trans.LogWarning(f"异常被忽略: {_e}") # 装饰器形式的存储类标记(@CExport / @CExtern / @State 等) deco_flags: dict[str, bool] = self._extract_decorator_storage_flags(Node) - if deco_flags['is_export'] or deco_flags['is_extern'] or deco_flags['is_state']: + _is_extern_node: bool = (bool(getattr(Node, 'Extern', False)) + or 'extern' in (getattr(Node, 'Markers', None) or ())) + if deco_flags['is_export'] or deco_flags['is_extern'] or deco_flags['is_state'] or _is_extern_node: Gen._export_funcs.add(FuncName) IsUserMarkedExport = True + if _is_extern_node: + Gen._export_extern_funcs[FuncName] = getattr(Gen, 'module_sha1', '') or '' # 注册当前模块定义的函数名,使 _mangle_func_name 跳过 _export_extern_funcs 检查 # (_export_extern_funcs 是跨模块共享集合,包含所有 CExtern 函数名;当前模块定义的 # 同名用户函数应使用 SHA1 前缀,而非被误判为外部 C 函数返回裸名)