Skip to content

Commit

Permalink
Fix panic for typdef void (#65)
Browse files Browse the repository at this point in the history
* get rid of panic for typedef void (interprets as typedef struct {} )
  • Loading branch information
g41797 authored Apr 11, 2023
1 parent 120c81d commit e489b85
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.testdata*/
/.examples/
.idea/
/dist/
/dist/
.vscode/
3 changes: 3 additions & 0 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ func (g *translator) convertDecl(d *cc.Declaration) []CDecl {
dname := dd.Name().String()
conf := g.idents[dname]
vt := g.convertTypeRootOpt(conf, dd.Type(), id.Position())
if isTypedef && vt == nil {
vt = types.StructT(nil)
}
var init Expr
if id.Initializer != nil && inCur {
if isTypedef {
Expand Down
18 changes: 17 additions & 1 deletion docs/quirks.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,20 @@ To solve this, `cxgo` emulates a virtual include file system at `/_cxgo_override
headers bundled into `cxgo`.

It serves two purposes: provides a zero-config experience for common use cases and allows `cxgo` to implement C stdlib
differently and adapt it to the needs of Go.
differently and adapt it to the needs of Go.

### typedef void

Example from struct_FILE.h:

typedef void _IO_lock_t;

_IO_lock_t *_lock;

For now `cxgo` interprets it as

typedef struct{} _IO_lock_t;




0 comments on commit e489b85

Please sign in to comment.