... | ... | @@ -29,3 +29,33 @@ TODO |
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
---
|
|
|
|
|
|
## Tool changes
|
|
|
|
|
|
### `hsc2hs` defines an `#alignment` macro
|
|
|
|
|
|
`hsc2hs` now supports the `#alignment` macro, which can be used to calculate the alignment of a struct in bytes. It is common for `.hsc` files to implement `#alignment` manually via a `#let` directive:
|
|
|
|
|
|
```
|
|
|
#let alignment t ="%lu",(unsigned long)offsetof(struct {char x__; t (y__);}, y__)
|
|
|
```
|
|
|
|
|
|
|
|
|
This command was incorporated into `hsc2hs` with the release of GHC 8.0. As a result, if you have the above directive in your code, it will now emit a warning when compiled with GHC 8.0:
|
|
|
|
|
|
```wiki
|
|
|
Module.hsc:24:0: warning: "hsc_alignment" redefined [enabled by default]
|
|
|
In file included from dist/build/Module_hsc_make.c:1:0:
|
|
|
/path/to/ghc/lib/template-hsc.h:88:0: note: this is the location of the previous definition
|
|
|
#define hsc_alignment(t...) \
|
|
|
^
|
|
|
```
|
|
|
|
|
|
|
|
|
To make your code free of warnings on GHC 8.0 and earlier versions, surround the directive with a pragma checking for the right GHC version:
|
|
|
|
|
|
```
|
|
|
#if __GLASGOW_HASKELL__ <800#let alignment t ="%lu",(unsigned long)offsetof(struct {char x__; t (y__);}, y__)#endif
|
|
|
``` |
|
|
\ No newline at end of file |