Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

fix(cl): preserve imports for types initialized across files

Chiusa
#1,041 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@luoliwoshang ci sta già lavorando.

Dal 13/10/2026.

  • #1042 di @luoliwoshang — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, cpp, go
Ambito
tooling

Direzione di ricerca

Start with the minimal reproduction: a forward declaration in a.h and the definition in b.h, mapped to separate outputs through GoFileOf. Check which Go file receives the imports for Point, and why c.Int and unsafe.Pointer end up in a file without them. Pull request #1042 is already open against this issue, so coordinate with it first. Done means a.go compiles with the right imports and aliases stay consistent regardless of traversal order.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

When a C/C++ record is declared in one header and defined in another header,
llcppg can generate the record in the Go file that owns the declaration while
collecting its field types from the definition's Go file. The generated type
then refers to imported types such as c.Int or unsafe.Pointer, but the
imports are attached to the wrong Go file.

Depending on source/file traversal order, this produces either missing imports
or inconsistent aliases such as c1.Int and unsafe1.Pointer.

Minimal Reproduction

a.h:

#pragma once
struct point;

b.h:

#pragma once
struct point {
    int x;
    void *data;
};

Generate one Go package from both headers and map them to separate output files:

GoFileOf("a.h") == "a.go"
GoFileOf("b.h") == "b.go"

The forward declaration creates Point in a.go. The later definition fills
that type with c.Int and unsafe.Pointer fields.

Actual Result

a.go can be generated as:

package multifile

type Point struct {
    X    c.Int
    Data unsafe.Pointer
}

but without the corresponding imports in a.go, resulting in undefined
identifiers. In larger bindings the same issue can instead appear as an alias
mismatch, for example an import of c with references to c1, or an import of
unsafe1 with references to unsafe.

Expected Result

The imports required by Point must be emitted in the same Go file as the
type declaration:

package multifile

import (
    "github.com/goplus/lib/c"
    "unsafe"
)

type Point struct {
    X    c.Int
    Data unsafe.Pointer
}

Import aliases and all references must agree within every generated Go file,
regardless of header traversal order.

Environment

  • llcppg current main branch
  • LLGo toolchain
  • C language mode
  • Multiple generated Go files selected through GoFileOf
Lingua principale
Go
Stelle
39
Fork
13
Merge medio
1h 28m
PR unite (30g)
256

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di goplus/llcppg

Tutte le issue di goplus/llcppg

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.