haskell / haskell/hsc2hs

hsc2hs doesn't work with floating-point consts in cross-compilation mode

Open
#90 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
46
Forks
30
PR merge metrics
No merged PRs in 30d

Description

If a const is defined as floating point or double, `--cross-compile` fails with:

```
MyLib.hsc: In function ‘_hsc2hs_test1’:
MyLib.hsc:5:20: error: storage size of ‘test_array’ isn’t constant
compilation failed
```

In the example above, `MyLib.hsc` has the following construct:
```
#const MY_CONST
```

and `MY_CONST` is defined in a header file with `#define MY_CONST ((double)-123456789.)`. This is the function it generates:
```
#include "/nix/store/sk5if9vmsykj16phb87wv7a8pv08wi62-ghc-9.6.5/lib/ghc-9.6.5/lib/template-hsc.h"
#include "../cbits/cross.h"
void _hsc2hs_test1()
{
#line 4 "MyLib.hsc"
{
static int test_array[(MY_CONST) > 0 ? 2 : 1];
(void)test_array;
}
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.