Skip to content

Commit 32bacd0

Browse files
committed
improve docs
1 parent 5b00177 commit 32bacd0

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

changelog.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@
126126
nim r compiler/nim.nim --fullhelp # no recompilation
127127
nim r --nimcache:/tmp main # binary saved to /tmp/main
128128
```
129-
- `incompleteStruct` is now deprecated, use `completeStruct` instead.
129+
- a new pragma `completeStruct` for importc objects indicates the type is fully
130+
specified in the nim declaration (including field ordering), and allows
131+
`sizeof, alignof, offsetof` to be used at compile time, see
132+
manual.html#implementation-specific-pragmas-completestruct-pragma.
133+
- `incompleteStruct` is now deprecated, see
134+
manual.html#implementation-specific-pragmas-incompletestruct-pragma.
130135

131136
## Tool changes
132137

compiler/pragmas.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
872872
noVal(c, it)
873873
incl(sym.flags, {sfThread, sfGlobal})
874874
of wDeadCodeElimUnused: deprecatedPragma(wDeadCodeElimUnused, "dead code elim always on")
875-
of wIncompleteStruct: deprecatedPragma(wIncompleteStruct, "see '$1' instead" % wCompleteStruct.canonPragmaSpelling)
875+
of wIncompleteStruct: deprecatedPragma(wIncompleteStruct, "see https://nim-lang.github.io/Nim/manual.html#implementation-specific-pragmas-incompletestruct-pragma")
876876
of wNoForward: pragmaNoForward(c, it)
877877
of wReorder: pragmaNoForward(c, it, flag = sfReorder)
878878
of wMagic: processMagic(c, it, sym)

doc/manual.rst

+11-2
Original file line numberDiff line numberDiff line change
@@ -6432,8 +6432,17 @@ at least `sizeof` is correct.
64326432
x2* {.importc: "_x2"}: pointer # renamed field
64336433
64346434
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
6436-
default.
6435+
6436+
6437+
IncompleteStruct pragma
6438+
-----------------------
6439+
**deprecated**
6440+
This was used for forwarded C declarations such as `DIR` on some platforms,
6441+
but led to incorrect typeinfo (eg with `dumpNumberOfInstances`). Instead we
6442+
simply avoid referring to such type by value on platforms where it's a forwarded
6443+
declaration and only use it via pointer. Any disallowed use-by-value leads to a
6444+
C codegen error, and we avoid silently wrong results for cases where
6445+
use-by-value is allowed.
64376446

64386447
Compile pragma
64396448
--------------

0 commit comments

Comments
 (0)