mirror of
https://github.com/KarolS/millfork.git
synced 2026-04-27 01:19:37 +00:00
Const arrays
This commit is contained in:
@@ -10,6 +10,8 @@ even up to hardware damage.
|
||||
|
||||
* array overruns: indexing past the end of an array leads to undefined behaviour
|
||||
|
||||
* writing to arrays defined as `const`
|
||||
|
||||
* stray pointers: indexing a pointer that doesn't point to a valid object or indexing it past the end of the pointed object leads to undefined behaviour
|
||||
|
||||
* reading uninitialized variables: will return undefined values
|
||||
|
||||
@@ -21,6 +21,8 @@ It is not allowed in any other places.
|
||||
|
||||
String literals can be used as either array initializers or expressions of type `pointer`.
|
||||
|
||||
String literals are equivalent to constanr arrays. Writing to them via their pointer is undefined behaviour.
|
||||
|
||||
If a string literal is used as an expression, then the text data will be located in the default code segment,
|
||||
regardless of which code segment the current function is located it. This may be subject to change in future releases.
|
||||
|
||||
|
||||
+3
-1
@@ -106,12 +106,14 @@ An array is a continuous sequence of bytes in memory.
|
||||
|
||||
Syntax:
|
||||
|
||||
`[segment(<segment>)] array [(<element type>)] <name> [[<size>]] [align ( <alignment> )] [@<address>] [= <initial_values>]`
|
||||
`[segment(<segment>)] [const] array [(<element type>)] <name> [[<size>]] [align ( <alignment> )] [@<address>] [= <initial_values>]`
|
||||
|
||||
* `<segment>`: segment name; if absent,
|
||||
then defaults to `default_code_segment` as defined for the platform if the array has initial values,
|
||||
or to `default` if it doesn't.
|
||||
|
||||
* if `const` is present, the array is read-only. Read-only arrays have to have a fixed address and/or defined contents.
|
||||
|
||||
* `<element type>`: type of the elements of the array.
|
||||
It must be of size 1 byte.
|
||||
If omitted, the default is `byte`.
|
||||
|
||||
Reference in New Issue
Block a user