Skip to content

Commit e9f095e

Browse files
committed
fixup
1 parent 9bb882e commit e9f095e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

doc/manual.rst

+12-11
Original file line numberDiff line numberDiff line change
@@ -6412,26 +6412,27 @@ CompleteStruct pragma
64126412
-----------------------
64136413
By default, `importc` types are considered incomplete: they may be lacking fields
64146414
in their nim declaration because these are unused in nim code or because of ABI
6415-
differences across platforms, in particular for padding fields. Field reordering
6415+
differences across platforms, in particular for padding fields. Field reorderings
64166416
are also allowed. This prevents using `sizeof`, `alignof`, `offsetOf` at compile
64176417
time.
6418-
These can still be used at runtime, deferring to calling ``sizeof`` (+ friends) in the
6418+
These can still be used at runtime, deferring to calling `sizeof` (+ friends) in the
64196419
backend generated code. In this case, they're known at backend compile time,
64206420
but not during nim semantic phase.
64216421

6422-
This ``completeStruct`` pragma overrides this behavior by telling the compiler
6423-
the type declaration in nim is fully specified, so that `sizeof`, `alignof`, `offsetOf`
6424-
are available at compile time. As a sanity check, `-d:checkAbi` will insert
6425-
cgen static checks to make sure at least sizeof is correct.
6422+
This `completeStruct` pragma overrides this behavior by telling the compiler
6423+
the type declaration in nim is fully specified and in correct order so that
6424+
`sizeof`, `alignof`, `offsetOf` are available at compile time.
6425+
As a sanity check, `-d:checkAbi` will insert backend static checks to make sure
6426+
at least `sizeof` is correct.
64266427

64276428
.. code-block:: Nim
64286429
type
6429-
TFoo* {.importc: "Foo", header: "<bar.h>",
6430-
pure, completeStruct.} = object
6431-
x*: cint # only 1 field in C declaration
6430+
TFoo* {.importc: "struct Foo", header: "<bar.h>", completeStruct.} = object
6431+
s1*: cint
6432+
x2* {.importc: "_x2"}: pointer # renamed field
64326433
6433-
See `tests <https://github.com/nim-lang/Nim/blob/devel/tests/misc/msizeof5.nim>`_
6434-
The ``incompleteStruct`` pragma is now deprecated as it was implying the wrong
6434+
See `additional examples <https://github.com/nim-lang/Nim/blob/devel/tests/misc/msizeof5.nim>`_.
6435+
The `incompleteStruct` pragma is now deprecated as it was implying the wrong
64356436
default.
64366437

64376438
Compile pragma

0 commit comments

Comments
 (0)