lynn / chibicc

A small C compiler… for uxn
MIT License
114 stars 4 forks source link

[bug?] function pointer typedefs don't seem to be usable #32

Open thacuber2a03 opened 1 year ago

thacuber2a03 commented 1 year ago

I'm trying to see if I can compile rxi's fe with chibicc-uxn, and the former has a bunch of function pointer typedefs it uses all around the code:

typedef fe_Object* (*fe_CFunc)(fe_Context *ctx, fe_Object *args);
typedef void (*fe_ErrorFn)(fe_Context *ctx,  char *err, fe_Object *cl);
typedef void (*fe_WriteFn)(fe_Context *ctx, void *udata, char chr);
typedef char (*fe_ReadFn)(fe_Context *ctx, void *udata);

the typedefs seem to be parsed, but when it comes to actually using them, the compiler fails:

read_file(): allocated 22919 bytes
tokenize(): allocated 453561 bytes (sizeof(Token) = 64)
tmp.c:8: typedef struct { fe_CFunc error; fe_CFunc mark, gc; } fe_Handlers;
                          ^ typename expected

I could definitely change them to void*s, but that would make some parts of the code hard to read (if you're not used to fe's source, which I am) this is my first issue, so I'm sorry if I'm missing on something, and I'll understand if they're not intended to be supported

thacuber2a03 commented 1 year ago

for now I'll change them to void*s and see if it does work edit: I completely forgot void*s can't be called