diff options
author | Ayke van Laethem <[email protected]> | 2019-11-06 14:02:18 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-11-06 15:54:18 +0100 |
commit | b41e58bcb4a769f0fbfd7d1c85aaeb239802dc4e (patch) | |
tree | e18fd040a5d1a7083d0bcd629dceec2f83a82110 /cgo/libclang.go | |
parent | 0db403dc0c073f767bf211baea5d9adfe327adc5 (diff) | |
download | tinygo-b41e58bcb4a769f0fbfd7d1c85aaeb239802dc4e.tar.gz tinygo-b41e58bcb4a769f0fbfd7d1c85aaeb239802dc4e.zip |
cgo: rename reserved field names like `type`
This commit renames reserved field names like `type` to `_type`, and in
turn renames those fields as well (recursively). This avoids name
clashes when a C struct contains a field named `type`, which is a
reserved keyword in Go.
For some details, see:
https://golang.org/cmd/cgo/#hdr-Go_references_to_C
Diffstat (limited to 'cgo/libclang.go')
-rw-r--r-- | cgo/libclang.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/cgo/libclang.go b/cgo/libclang.go index a4817a4f1..1cbc78c44 100644 --- a/cgo/libclang.go +++ b/cgo/libclang.go @@ -605,6 +605,7 @@ func (p *cgoPackage) makeASTRecordType(cursor C.GoCXCursor, pos token.Pos) (*ast }{fieldList, p, &inBitfield, &bitfieldNum, &bitfieldList}) defer storedRefs.Remove(ref) C.tinygo_clang_visitChildren(cursor, C.CXCursorVisitor(C.tinygo_clang_struct_visitor), C.CXClientData(ref)) + renameFieldKeywords(fieldList) switch C.tinygo_clang_getCursorKind(cursor) { case C.CXCursor_StructDecl: return &ast.StructType{ |