Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#1,041 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@luoliwoshang ya está trabajando en esto.

Desde el 13/10/2026.

  • #1042 de @luoliwoshang — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, cpp, go
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Go
Estrellas
39
Forks
13
Merge medio
1 h 27 min
PR fusionados (30 d)
256

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de goplus/llcppg

Todos los issues de goplus/llcppg

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.