Skip to content

Two c_imports whose headers #define the same macro: "failed to compile C header snippet" for the second #1753

Closed

Description

@ehartford

Spec: §16.2 (c_import), §18.2 (D70: a use c_import(...) is an import; the later import shadows the earlier).

Repro (installed main, and branch ruled-fixes):

a.h: #define PI 3
b.h: #define PI 4

use c_import("a.h")
use c_import("b.h")
fn main:
    print(PI)

Actual: error: failed to compile C header snippet: b.h at the end of the file. Each header alone works (b.h alone prints 4).

Expected: both import; under D70 bare PI is b.h's (the later import) and a.PI / b.PI reach each (the namespaces landed on ruled-fixes). The cross-c_import dedup (ci_mark_cached_names) is the likely suspect: the second translation of a name the first already produced fails instead of producing the header's own value.

Found while writing D70 tests; the tests use one header and std.math instead.

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