id |
ftwikibooks:enwikibooks:38527:219955
|
record_format |
openpolar
|
spelling |
ftwikibooks:enwikibooks:38527:219955 2023-06-11T04:17:19+02:00 Wikibooks: BlitzMax/Language/Pointers https://en.wikibooks.org/wiki/BlitzMax/Language/Pointers eng eng Book ftwikibooks 2023-05-02T14:50:21Z BlitzMax supports C style pointers for use by code that must perform low level interaction with the operating system and/or speed sensitive code. Pointers are not recommended for general use as misuse of pointers can easily result in memory corruption causing all sorts of bugs and headaches! Pointers may be declared by appending Ptr to the type of a variable or function declaration. For example Local int Ptr Int Ptr Note the pointers are only supported for the primitive numeric types Byte Short Int Long Float and Double. The [[Varptr]] operator allows you to find the address of a variable yielding a pointer. For example Local an int Int=10 Local int ptr Int Ptr=Varptr an int Array style indexing is used to dereference pointers Local an int Int=10 Local int ptr Int Ptr=Varptr an int Print int ptr[0] BlitzMax will automatically convert any pointer type to a byte pointer for you. In addition objects and arrays may be assigned to byte pointers. In the case of objects the pointer will contain the address of the first field of the object. In the case of arrays the pointer will contain the address of the first element of the array. Be very careful when assigning objects to pointers as there is a danger that the garbage collector will reclaim the object before you have finished with the pointer! It is recommended that you use [[GCSuspend]] and [[GCResume]] around code that converts objects to pointers. You may also explicitly cast pointers to and from other pointers and to and from Int. For example Local an int Int=10 Local int ptr Int Ptr=Varptr an int Local float ptr Float Ptr=Float Ptr int ptr Local var address Int=Int float ptr Comment BlitzMax also supports pointer arithmetic using the standard + and operators. BookCat Book The Pointers WikiBooks - Open-content textbooks
|
institution |
Open Polar
|
collection |
WikiBooks - Open-content textbooks
|
op_collection_id |
ftwikibooks
|
language |
English
|
description |
BlitzMax supports C style pointers for use by code that must perform low level interaction with the operating system and/or speed sensitive code. Pointers are not recommended for general use as misuse of pointers can easily result in memory corruption causing all sorts of bugs and headaches! Pointers may be declared by appending Ptr to the type of a variable or function declaration. For example Local int Ptr Int Ptr Note the pointers are only supported for the primitive numeric types Byte Short Int Long Float and Double. The [[Varptr]] operator allows you to find the address of a variable yielding a pointer. For example Local an int Int=10 Local int ptr Int Ptr=Varptr an int Array style indexing is used to dereference pointers Local an int Int=10 Local int ptr Int Ptr=Varptr an int Print int ptr[0] BlitzMax will automatically convert any pointer type to a byte pointer for you. In addition objects and arrays may be assigned to byte pointers. In the case of objects the pointer will contain the address of the first field of the object. In the case of arrays the pointer will contain the address of the first element of the array. Be very careful when assigning objects to pointers as there is a danger that the garbage collector will reclaim the object before you have finished with the pointer! It is recommended that you use [[GCSuspend]] and [[GCResume]] around code that converts objects to pointers. You may also explicitly cast pointers to and from other pointers and to and from Int. For example Local an int Int=10 Local int ptr Int Ptr=Varptr an int Local float ptr Float Ptr=Float Ptr int ptr Local var address Int=Int float ptr Comment BlitzMax also supports pointer arithmetic using the standard + and operators. BookCat
|
format |
Book
|
title |
Wikibooks: BlitzMax/Language/Pointers
|
spellingShingle |
Wikibooks: BlitzMax/Language/Pointers
|
title_short |
Wikibooks: BlitzMax/Language/Pointers
|
title_full |
Wikibooks: BlitzMax/Language/Pointers
|
title_fullStr |
Wikibooks: BlitzMax/Language/Pointers
|
title_full_unstemmed |
Wikibooks: BlitzMax/Language/Pointers
|
title_sort |
wikibooks: blitzmax/language/pointers
|
url |
https://en.wikibooks.org/wiki/BlitzMax/Language/Pointers
|
genre |
The Pointers
|
genre_facet |
The Pointers
|
_version_ |
1768376380594061312
|