objc/test/parserexpf_demo.m · 2911 字节 · 下载原文
// ⚠ 这一行 `extern` 是**普通 C 函数声明,不是 UI 库**(`parserexpf` 属 `Lib/shared/parserexpf.c`)。
// ⚠ This `extern` is a **plain C function declaration, not the UI library** (`parserexpf` lives in `Lib/shared/parserexpf.c`).
// 为什么不能换成一条 `#import`(2026-10-01 实测,不是没试):
// Why it cannot be replaced by an `#import` (measured 2026-10-01, not for lack of trying):
// · `Lib/c/shared_bindings.h`(**唯一**声明了 `parserexpf` 的头)在 ObjC 前端编不过:
// · `Lib/c/shared_bindings.h` (the **only** header declaring `parserexpf`) does not compile in the ObjC frontend:
// 先要 `#include <stddef.h>`(否则 `size_t`/`wchar_t` 不认识),再撞上 `int mutex_lock(int id)`
// it first needs `#include <stddef.h>` (else `size_t`/`wchar_t` are unknown), then hits `int mutex_lock(int id)`
// 那两个 `id` 形参 ⇒ `expected )(得到 IdType 'id')`。
// where `id` is a reserved type name ⇒ `expected ) (got IdType 'id')`.
// · `Lib/objc/shared.h`(ObjC 自己的绑定头)**通篇是注释**,不产生任何声明。
// · `Lib/objc/shared.h` (ObjC's own bindings header) is **comments only** and declares nothing.
// ⇒ 本仓目前**没有 ObjC 能用的 `parserexpf` 声明头**,这一行 `extern` 只能留着。
// ⇒ This repo currently has **no ObjC-usable declaration header for `parserexpf`**, so this `extern` stays.
// ⚠ 另:本示例实测打印 `Float: 0.000000`(期望 `7.000000`)—— 同一段代码在 C 前端也打印垃圾,
// ⚠ Note: this demo actually prints `Float: 0.000000` (expected `7.000000`) — the same code prints garbage in the C frontend too,
// 属 double 返回值传递链,**不是 ObjC 独有**,本轮未修、未深挖。
// so it is a double-return-value chain issue, **not ObjC-specific**; not fixed or investigated further this round.
// ✅ 2026-10-04 复验:本示例仍打印 `Float: 0.000000`(double 返回值链,仍成立);`Lib/c/shared_bindings.h` 在 ObjC 前端**仍然编不过**,
// ✅ Re-measured 2026-10-04: this demo still prints `Float: 0.000000` (double-return chain, still holds); `Lib/c/shared_bindings.h` **still fails to compile** under the ObjC frontend,
// 但**首个拦路者换了**:现在是第 364 行的 `objc_count(int* self)`(`self` 是保留类型名 ⇒ `expected )(得到 Self 'self')`),不再是 `id`;`Lib/objc/shared.h` 仍是通篇注释。
// though **the first blocker changed**: it is now `objc_count(int* self)` at line 364 (`self` is a reserved type name ⇒ `expected ) (got Self 'self')`), no longer `id`; `Lib/objc/shared.h` is still comments-only.
#include <stdio.h>
extern double parserexpf(const char *e);
int main() { printf("Float: %f\n", parserexpf("2.5+3*1.5")); return 0; }