fix(cl): preserve imports for types initialized across files
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de goplus/llcppg
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
feature proposal
Dificultad 5/5 Más de una semana Aptitud para principiantes 18/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Architecture-Design feature to be confirm
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de goplus/llcppg
Issues similares
-
os: RawConn methods of a closed File return internal/poll.ErrFileClosing instead of ErrClosedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
[Bug]: Bedrock invoke-with-response-stream reports `stop_reason: "end_turn"` for tool-use turnsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
oalders/clodhopper#162 ·
Los mantenedores suelen responder en 1 día
-
component/server severity/minor type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
diagnose globalnet reports a failure for every exported headless ServicePosiblemente ocupada @kurtyoon la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
submariner-io/subctl#1948 ·
Los mantenedores suelen responder en 1 día