gotranspile / cxgo

Tool for transpiling C to Go.
https://gotranspile.dev
MIT License
328 stars 22 forks source link

get rid of panic for typedef void (interprets as typedef int8_t) #64

Closed g41797 closed 1 year ago

g41797 commented 1 year ago

For discussion only

g41797 commented 1 year ago

C: typedef _int8t IOTEST_t; IOTEST_t *test;

go: type IOTEST_t int8 var test *IOTEST_t

C: typedef void IOTEST_t; var test *IOTEST_t

go: type IOTEST_t int8 var test unsafe.Pointer

After discussion I'll revert this PR

dennwc commented 1 year ago

As discussed in PM, it should probably use struct{} instead of int8.

g41797 commented 1 year ago

for int8_t i added following code: if isTypedef && vt == nil { vt = types.IntT(1) }

the same code for struct uses StructT(nil)

for C code typedef void IOTEST_t;

void main() { IOTEST_t *test; }

created go code: import "unsafe"

type IOTEST_t struct { }

func main() { var test unsafe.Pointer _ = test }

is it enough?

btw func (t *StructType) Sizeof() int { should return 1 for fieldless struct is it OK?

On Mon, Apr 10, 2023 at 10:28 AM Denys Smirnov @.***> wrote:

As discussed in PM, it should probably use struct{} instead of int8.

— Reply to this email directly, view it on GitHub https://github.com/gotranspile/cxgo/pull/64#issuecomment-1501498787, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFRU6LRNNEWN4MELTAG46LXAOZCZANCNFSM6AAAAAAWYFBOSQ . You are receiving this because you authored the thread.Message ID: @.***>