corrode
corrode copied to clipboard
Fails on global uninitialised structs
Consider the following C code:
typedef struct _test test;
struct _test {
int test;
};
static test bar;
Corrode fails:
$ corrode uninitialized-global.c
("uninitialized-global.c": line 7): illegal initializer; check whether a real C compiler accepts this:
{ }
gcc accepts it:
$ gcc -c uninitialized-global.c -o test.o
$ echo $?
0
I would be willing to provide a patch if I had a rough idea on where to look and to approach the problem. (I got the Rust experience and a bit of Haskell, but not the Corrode experience)
https://github.com/jameysharp/corrode/blob/34053342c2f1ca04f23ad94d67057f14e74d9fb9/src/Language/Rust/Corrode/C.md#declarations i guess
try import Debug.Trace (trace)
then expr <- trace ("faulty Ctype maybe? " ++ show ty) $ interpretInitializer ty (fromMaybe (CInitList [] node) minit)