diff --git a/cl/compile.go b/cl/compile.go index be978fc43..7aea9a450 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -23,6 +23,7 @@ import ( "github.com/goplus/gogen" "github.com/goplus/llcppg/clang" + lc "github.com/llarhub/clang-c" ) const ( @@ -286,6 +287,14 @@ func loadFiles(ctx *pkgCtx, files []Source, myPkgPath string, goFileOf func(head clang.VisitChildren(f.Cursor(), func(decl, parent clang.Cursor) clang.ChildVisitResult { if pkgOf != nil { at := clang.PresumedFile(decl.Location()) + switch decl.Kind { + case lc.Cursor_ClassDecl, lc.Cursor_StructDecl: + if decl.IsCursorDefinition() == 0 { + if definition := decl.Definition(); definition.IsNull() == 0 { + at = clang.PresumedFile(definition.Location()) + } + } + } if _, ok := lastSeen[at]; ok { return clang.Continue // already loaded } diff --git a/tool/_testc/python-3.14.8/cpython-pythread.go b/tool/_testc/python-3.14.8/cpython-pythread.go index 461353b06..2a58460e0 100644 --- a/tool/_testc/python-3.14.8/cpython-pythread.go +++ b/tool/_testc/python-3.14.8/cpython-pythread.go @@ -3,10 +3,15 @@ package py import ( - c1 "github.com/goplus/lib/c" + "github.com/goplus/lib/c" "github.com/goplus/lib/c/pthread" _ "unsafe" ) +type X_PyTssT struct { + X_isInitialized c.Int + X_key pthread.Key +} + //go:linkname PY_TIMEOUT_MAX C.PY_TIMEOUT_MAX -var PY_TIMEOUT_MAX c1.LongLong +var PY_TIMEOUT_MAX c.LongLong diff --git a/tool/_testc/python-3.14.8/pythread.go b/tool/_testc/python-3.14.8/pythread.go index 8ab5457d6..5691553b7 100644 --- a/tool/_testc/python-3.14.8/pythread.go +++ b/tool/_testc/python-3.14.8/pythread.go @@ -13,8 +13,4 @@ const ( ) type PyThreadTypeLock uintptr -type X_PyTssT struct { - X_isInitialized c1.Int - X_key pthread.Key -} type PyTssT = X_PyTssT