FromRawPointer

FromRawPointer[p]

returns the value referred to by the pointer p for use in compiled code.

FromRawPointer[array,offset]

returns the value of a C array at an offset.

Details

  • FromRawPointer is only available in compiled code.
  • Running FromRawPointer on invalid inputs can lead to crashes.
  • FromRawPointer can work with pointers and arrays.
  • Usages of FromRawPointer have the following approximate equivalents in C:
  • FromRawPointer[p]*p
    FromRawPointer[array,offset]array[offset] or *(array+offset)

Examples

open allclose all

Basic Examples  (1)

Create a pointer to an integer, then dereference it:

Scope  (1)

Offset  (1)

FromRawPointer can extract different elements of an array:

Applications  (2)

Represent a library function that returns its results by modifying a pointer:

Compile a program that uses the function:

Represent a library function that populates a "CArray" with a sequence of square numbers:

Compile a program that uses FromRawPointer to extract elements of the populated array:

Wolfram Research (2022), FromRawPointer, Wolfram Language function, https://reference.wolfram.com/language/ref/FromRawPointer.html.

Text

Wolfram Research (2022), FromRawPointer, Wolfram Language function, https://reference.wolfram.com/language/ref/FromRawPointer.html.

CMS

Wolfram Language. 2022. "FromRawPointer." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FromRawPointer.html.

APA

Wolfram Language. (2022). FromRawPointer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FromRawPointer.html

BibTeX

@misc{reference.wolfram_2023_fromrawpointer, author="Wolfram Research", title="{FromRawPointer}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/FromRawPointer.html}", note=[Accessed: 29-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_fromrawpointer, organization={Wolfram Research}, title={FromRawPointer}, year={2022}, url={https://reference.wolfram.com/language/ref/FromRawPointer.html}, note=[Accessed: 29-March-2024 ]}