Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ
#1,041 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@luoliwoshang がすでに取り組んでいます。

2026年10月13日 から。

  • #1042 @luoliwoshang による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, cpp, go
領域
tooling

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Go
スター
39
フォーク
13
平均マージ
1時間 28分
マージ済み PR(30日)
256

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

goplus/llcppg のほかの issue

goplus/llcppg の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。