mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-10 05:38:10 +00:00
follow @Vindaar's advice
This commit is contained in:
@@ -192,12 +192,13 @@ else:
|
||||
|
||||
proc `addr`*[T](x: var T): ptr T {.magic: "Addr", noSideEffect.} =
|
||||
## Builtin `addr` operator for taking the address of a memory location.
|
||||
## This works even for `let` variables or parameters
|
||||
## for better interop with C.
|
||||
##
|
||||
## .. note:: When you use it to write a wrapper for a C library, you should
|
||||
## always check that the original library does never write to data behind the
|
||||
## pointer that is returned from this procedure.
|
||||
## .. note:: This works for `let` variables or parameters
|
||||
## for better interop with C. When you use it to write a wrapper
|
||||
## for a C library and take the address of `let` variables or parameters,
|
||||
## you should always check that the original library
|
||||
## does never write to data behind the pointer that is returned from
|
||||
## this procedure.
|
||||
##
|
||||
## Cannot be overloaded.
|
||||
##
|
||||
@@ -215,12 +216,14 @@ proc `addr`*[T](x: var T): ptr T {.magic: "Addr", noSideEffect.} =
|
||||
proc unsafeAddr*[T](x: T): ptr T {.magic: "Addr", noSideEffect,
|
||||
deprecated: "'unsafeAddr' is a deprecated alias for 'addr'".} =
|
||||
## Builtin `addr` operator for taking the address of a memory
|
||||
## location. This works even for `let` variables or parameters
|
||||
## for better interop with C.
|
||||
## location.
|
||||
##
|
||||
## .. note:: When you use it to write a wrapper for a C library, you should
|
||||
## always check that the original library does never write to data behind the
|
||||
## pointer that is returned from this procedure.
|
||||
## .. note:: This works for `let` variables or parameters
|
||||
## for better interop with C. When you use it to write a wrapper
|
||||
## for a C library and take the address of `let` variables or parameters,
|
||||
## you should always check that the original library
|
||||
## does never write to data behind the pointer that is returned from
|
||||
## this procedure.
|
||||
##
|
||||
## Cannot be overloaded.
|
||||
discard
|
||||
|
||||
Reference in New Issue
Block a user