nim-lang / c2nim

c2nim is a tool to translate Ansi C code to Nim. The output is human-readable Nim code that is meant to be tweaked by hand before and after the translation process.
MIT License
502 stars 62 forks source link

handle __attribute__ pragmas in struct bodies, more pointer decls, etc #252

Closed elcritch closed 1 year ago

elcritch commented 1 year ago

Ok, I slimmed down the large test file and cherry picked a some of the examples from the running cc -E.

This includes glorious C examples like:

void(*signal(int, void (*)(int)))(int);
int vasprintf(char ** restrict, const char * restrict, __gnuc_va_list) __attribute__((__format__ (__printf__, 2, 0)));

I honestly still can't grok the signal one. cdecl.org explains it as:

declare signal as function (int, pointer to function (int) returning void) returning pointer to function (int) returning void

Which seems to match the new output:

var signal*: proc (a1: cint; a2: proc (a1: cint)): proc (a1: cint)
elcritch commented 1 year ago

@Araq you think this is good to merge now?