Variables & kind of memory
    Alain De Vos 
    devosalain at ymail.com
       
    Sat Apr 23 03:41:17 UTC 2022
    
    
  
I wrote a simple test program:
```
import std.stdio:writefln;
int [] GLV=[1,2];
int [2] GLF=[1,2];
static int [] GSLV=[1,2];
static int [2] GSLF=[1,2];
void main(){
writefln("-------------");
writefln("GLV:address :%12x:AAA",&GLV);
writefln("GLF:address :%12x:AAA",&GLF);
writefln("GSLV:address:%12x:AAA",&GSLV);
writefln("GSLF:address:%12x:AAA",&GSLF);
writefln("GLV:ptr     :%12x:BBB",GLV.ptr);
writefln("GLF:ptr     :%12x:AAA",GLF.ptr);
writefln("GSLV:ptr    :%12x:BBB",GSLV.ptr);
writefln("GSLF:ptr    :%12x:AAA",GSLF.ptr);
int [] LV=[1,2];
int [2] LF=[1,2];
static int [] SLV=[1,2];
static int [2] SLF=[1,2];
writefln("------------");
writefln(".LV:address :%12x:stack",&LV);
writefln(".LF:address :%12x:stack",&LF);
writefln(".SLV:address:%12x:AAA",&SLV);
writefln(".SLF:address:%12x:AAA",&SLF);
writefln(".LV:ptr     :%12x:heap",LV.ptr);
writefln(".LF:ptr     :%12x:stack",LF.ptr);
writefln(".SLV:ptr    :%12x:BBB",SLV.ptr);
writefln(".SLF:ptr    :%12x:AAA",SLF.ptr);
```
Which outputs:
```
-------------
GLV:address :   8002d6120:AAA
GLF:address :   8002d6130:AAA
GSLV:address:   8002d6138:AAA
GSLF:address:   8002d6148:AAA
GLV:ptr     :      298808:BBB
GLF:ptr     :   8002d6130:AAA
GSLV:ptr    :      298810:BBB
GSLF:ptr    :   8002d6148:AAA
------------
.LV:address :7fffffffdfd0:stack
.LF:address :7fffffffdfc8:stack
.SLV:address:   8002d6150:AAA
.SLF:address:   8002d6160:AAA
.LV:ptr     :   801000000:heap
.LF:ptr     :7fffffffdfc8:stack
.SLV:ptr    :      298818:BBB
.SLF:ptr    :   8002d6160:AAA
```
The output has clearly 4 different kind of memory regions.
I have stack and heap, but don't know what AAA & BBB regions are.
Feel free to elaborate.
    
    
More information about the Digitalmars-d-learn
mailing list