Hello,
I try to create a big array with 3 dimensions but when i compile the code, an error appears
I don't undestand why ?
I use :
FreeBASIC-1.09.0-winlibs-gcc-9.3.0
FBIde0.4.6r4
The compiler path is : C:\FreeBasic\fbc64.exe
The compiler command is : "<$fbc>" "<$file>" -arch x86-64
Code:
'----------------------------------------------------------
dim as integer x,y,z
const xmax = 2000
const ymax = 2000
const zmax = 70
dim shared as single arraya(zmax,ymax,xmax)
dim shared as single arrayb(zmax,ymax,xmax)
screenres 800,600,32
for z=0 to zmax
for y=0 to ymax
for x=0 to xmax
arraya(z,y,x)=1.234
arrayb(z,y,x)=5.678
next
next
next
? arraya(2,2,2)
? arrayb(2,2,2)
sleep
'--------------------------------------------------------------
Command executed:
"C:\FreeBasic\fbc64.exe" "C:\Users\roberto\Desktop\test limit mem.bas" -arch x86-64
Compiler output:
C:\FreeBasic\lib\win64\crt2.o: in function `__tmainCRTStartup':
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:259:(.text+0x1cd): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_Sleep' defined in .idata$5 section in C:\FreeBasic\lib\win64/libkernel32.dll.a(dclps01409.o)
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:286:(.text+0x25a): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_SetUnhandledExceptionFilter' defined in .idata$5 section in C:\FreeBasic\lib\win64/libkernel32.dll.a(dclps01393.o)
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:294:(.text+0x288): relocation truncated to fit: R_X86_64_PC32 against symbol `__mingw_winmain_hInstance' defined in COMMON section in C:\FreeBasic\lib\win64\crt2.o
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:320:(.text+0x2ec): relocation truncated to fit: R_X86_64_PC32 against symbol `__mingw_winmain_lpCmdLine' defined in COMMON section in C:\FreeBasic\lib\win64\crt2.o
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:246:(.text+0x465): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_GetStartupInfoA' defined in .idata$5 section in C:\FreeBasic\lib\win64/libkernel32.dll.a(dclps00742.o)
C:\FreeBasic\lib\win64/libfb.a(init.o):init.c:(.text+0x2): relocation truncated to fit: R_X86_64_PC32 against `.bss'
C:\FreeBasic\lib\win64/libfb.a(init.o):init.c:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against `.bss'
C:\FreeBasic\lib\win64/libfb.a(init.o):init.c:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `__fb_ctx' defined in COMMON section in C:\FreeBasic\lib\win64/libfb.a(init.o)
C:\FreeBasic\lib\win64/libfb.a(init.o):init.c:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against `.bss'
C:\FreeBasic\lib\win64/libfb.a(init.o):init.c:(.text+0x73): relocation truncated to fit: R_X86_64_PC32 against symbol `__fb_ctx' defined in COMMON section in C:\FreeBasic\lib\win64/libfb.a(init.o)
C:\FreeBasic\lib\win64/libfb.a(init.o):init.c:(.text+0x84): additional relocation overflows omitted from the output
Results:
Compilation failed
System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win64 (64bit)
OS: Windows NT 6.2 (build 9200)
error if array bigger than 2 Gb on a 64 bit system
Re: error if array bigger than 2 Gb on a 64 bit system
You must declare dynamic arrays (the memory used by a dynamic array to store its elements is allocated at run-time in the heap).
For example:
For example:
Code: Select all
redim shared as single arraya(zmax,ymax,xmax)
redim shared as single arrayb(zmax,ymax,xmax)
Re: error if array bigger than 2 Gb on a 64 bit system
Thank you very much FXM, it works!
Re: error if array bigger than 2 Gb on a 64 bit system
For a fixed-length array, the data is either allocated on the program stack, or in the .BSS/.DATA section of the executable depending on whether this array was declared with Static (or Shared).
For a variable-length array:
- only the array descriptor is either allocated on the program stack, or in the .BSS/.DATA section of the executable depending on whether this array was declared with Static (or Shared),
- on the other hand the array elements are always allocated in the heap.
For a variable-length array:
- only the array descriptor is either allocated on the program stack, or in the .BSS/.DATA section of the executable depending on whether this array was declared with Static (or Shared),
- on the other hand the array elements are always allocated in the heap.