Skip to content

c_import (Windows): after #1396 the bzip2/libcurl windows.h bindings still fail to type-check — inline bodies over opaque records, with_memset, bool macro typed c_int, uppercase macro params #1417

Closed

Description

@ehartford

Context

On branch fix-1396-anon-file-scope-struct (stacked on #1399), with check src/main.w of the bzip2 and libcurl release UAT projects on native Windows 10 x64 gets past #1396 (unnamed file-scope records), sizeof[*mut c_void]() parsing, member records held through arrays, nested tags, and the _-tag / pack(2) layout demotions. The windows.h closure now fails in Sema with these classes (bzip2; libcurl is the same set). Stage2 of that branch, C:\Users\Eric\triage\fix1396, logs C:\Users\Eric\triage\check-1396-{bzip2,libcurl}.log.

count error example (generated binding line)
65 + 6 field access requires a concrete struct or union type; this type is opaque / null requires pointer type context winnt.h's FORCEINLINE TpInitializeCallbackEnviron: ((*__param_CallbackEnviron).Version = ((3 as c_ulong))) — _TP_CALLBACK_ENVIRON_V3 holds a bitfield member record, so it is opaque (§16.9); the inline body that writes its fields is still emitted. Before the demotion fix it compiled against a layout with every bitfield a whole DWORD. Also (*__param_Definition)... in the ACL/RtlSecureZeroMemory-style helpers.
2–4 undefined variable with_memset with_memset((__param_Config as *mut u8), (0 as c_int), ((sizeof[_CUSTOM_SYSTEM_EVENT_TRIGGER_CONFIG]() as c_ulonglong) as i64)) — an inline body's memset lowers to with_memset, which the c_import preamble does not declare (it declares with_alloc/with_free/...; with_* is also D30-deprecated in generated user-facing code).
1 type mismatch in binding let WINAPI_PARTITION_DESKTOP: c_int = (WINAPI_FAMILY == 100) — a comparison macro typed c_int.
1 'ENUMTYPE' is neither a variant ... a binding starts with a lowercase letter (§9.7) fn DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE: i32) -> Unit: return — an empty function-like macro emitted as a function whose uppercase parameter name is refused.

Also seen, unverified: extern fn RtlValidateCorrelationVector(__param_Vector: *mut CORRELATION_VECTOR) -> Never.

Expected

Per No Silent Fallbacks: an inline function whose body touches a record c_import imports opaque is omitted with a manifest entry (like other untranslatable functions), never emitted to fail at check; memset/memcpy in translated bodies use a surface the generated module declares; a macro's type follows its value; macro parameter names are escaped to bindings.

Blocks release-bzip2-uat / release-libcurl-uat on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions