diff options
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | docs/users_guide/7.12.1-notes.rst | 26 | ||||
-rw-r--r-- | docs/users_guide/utils.rst | 4 |
2 files changed, 30 insertions, 0 deletions
diff --git a/docs/users_guide/7.12.1-notes.rst b/docs/users_guide/7.12.1-notes.rst index 749f7afbc1..d443a0a65e 100644 --- a/docs/users_guide/7.12.1-notes.rst +++ b/docs/users_guide/7.12.1-notes.rst @@ -321,6 +321,32 @@ Package system - TODO FIXME. +hsc2hs +~~~~~~ + +- ``hsc2hs`` now supports the ``#alignment`` macro, which can be used to + calculate the alignment of a struct in bytes. Previously, ``#alignment`` + had to be implemented manually via a ``#let`` directive, e.g., :: + + #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__) + + As a result, if you have the above directive in your code, it will now emit + a warning when compiled with GHC 8.0. :: + + 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 still support 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 + Libraries --------- diff --git a/docs/users_guide/utils.rst b/docs/users_guide/utils.rst index 9c1237dd02..f490bfa2d8 100644 --- a/docs/users_guide/utils.rst +++ b/docs/users_guide/utils.rst @@ -224,6 +224,10 @@ Meanings of specific keywords: Computes the size, in bytes, of ``struct_type``. It will have type ``Int``. +``#alignment ⟨struct_type⟩`` + Computes the alignment, in bytes, of ``struct_type``. It will have type + ``Int``. + ``#enum ⟨type⟩, ⟨constructor⟩, ⟨value⟩, ⟨value⟩, ...`` A shortcut for multiple definitions which use ``#const``. Each ``value`` is a name of a C integer constant, e.g. enumeration value. |