05-19-2025, 02:25 AM
I'm working on an electrical engineering study app. In the code, I have a dynamic array ($DYNAMIC) that I initially declare as:
DIM SHARED AS STRING segment(1).
Further on in the program, as new segments are added, the program does this:
REDIM _PRESERVE segment AS STRING.
BUT! When I am loading a data file of an existing study, the line is:
REDIM _PRESERVE segment * 57 AS STRING.
I need a 57-character string to fit the width of an InForm listbox. The interesting thing is, the IDE doesn't indicate an error, but when I compile the app I get:
'C++ Compilation failed (Check .\internal\temp\compilelog.txt) error in the IDE
Looking at the compile log, I get:
Obviously, it must be an error to redim a string array with a fixed length after it was DIM'ed without a fixed length. If this is the proper behavior, the wiki doesn't indicate it. What is interesting is that the IDE didn't flag the error.
Thoughts?
DIM SHARED AS STRING segment(1).
Further on in the program, as new segments are added, the program does this:
REDIM _PRESERVE segment AS STRING.
BUT! When I am loading a data file of an existing study, the line is:
REDIM _PRESERVE segment * 57 AS STRING.
I need a 57-character string to fit the width of an InForm listbox. The interesting thing is, the IDE doesn't indicate an error, but when I compile the app I get:
'C++ Compilation failed (Check .\internal\temp\compilelog.txt) error in the IDE
Looking at the compile log, I get:
Code: (Select All)
internal\c\c_compiler\bin\c++.exe -std=gnu++17 -fno-strict-aliasing -Wno-conversion-null -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/include -Iinternal\c/parts/core/freeglut/include -Iinternal\c/parts/core/glew/include -DDEPENDENCY_IMAGE_CODEC -DDEPENDENCY_SOCKETS -DDEPENDENCY_PRINTER -DDEPENDENCY_ICON -DDEPENDENCY_NO_SCREENIMAGE -DCURL_STATICLIB -Iinternal\c/parts/network/http/include internal\c/qbx.cpp -c -o internal\c/qbx.o
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4689:5: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4689 | if (__ARRAY_STRING57_SEGMENTS[2]&2){
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4692:25: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'
4692 | ((mem_lock*)((ptrszint*)__ARRAY_STRING57_SEGMENTS)[8])->id=(++mem_lock_id);
| ^
internal\c/../temp/main.txt:4693:5: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4693 | if (__ARRAY_STRING57_SEGMENTS[2]&1){
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4694:5: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4694 | if (__ARRAY_STRING57_SEGMENTS[2]&4){
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4695:28: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4695 | cmem_dynamic_free((uint8*)(__ARRAY_STRING57_SEGMENTS[0]));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4697:14: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4697 | free((void*)(__ARRAY_STRING57_SEGMENTS[0]));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4700:1: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4700 | __ARRAY_STRING57_SEGMENTS[4]= 0 ;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4701:1: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4701 | __ARRAY_STRING57_SEGMENTS[5]=( 1 )-__ARRAY_STRING57_SEGMENTS[4]+1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4701:36: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4701 | __ARRAY_STRING57_SEGMENTS[5]=( 1 )-__ARRAY_STRING57_SEGMENTS[4]+1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4702:1: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4702 | __ARRAY_STRING57_SEGMENTS[6]=1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4703:5: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4703 | if (__ARRAY_STRING57_SEGMENTS[2]&4){
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4704:1: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4704 | __ARRAY_STRING57_SEGMENTS[0]=(ptrszint)cmem_dynamic_malloc(__ARRAY_STRING57_SEGMENTS[5]*57);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4704:60: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4704 | __ARRAY_STRING57_SEGMENTS[0]=(ptrszint)cmem_dynamic_malloc(__ARRAY_STRING57_SEGMENTS[5]*57);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4705:16: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4705 | memset((void*)(__ARRAY_STRING57_SEGMENTS[0]),0,__ARRAY_STRING57_SEGMENTS[5]*57);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4705:48: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4705 | memset((void*)(__ARRAY_STRING57_SEGMENTS[0]),0,__ARRAY_STRING57_SEGMENTS[5]*57);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4707:1: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4707 | __ARRAY_STRING57_SEGMENTS[0]=(ptrszint)calloc(__ARRAY_STRING57_SEGMENTS[5]*57,1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4707:47: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4707 | __ARRAY_STRING57_SEGMENTS[0]=(ptrszint)calloc(__ARRAY_STRING57_SEGMENTS[5]*57,1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4708:6: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4708 | if (!__ARRAY_STRING57_SEGMENTS[0]) error(257);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:4710:1: error: use of undeclared identifier '__ARRAY_STRING57_SEGMENTS'; did you mean '__ARRAY_STRING_SEGMENTS'?
4710 | __ARRAY_STRING57_SEGMENTS[2]|=1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| __ARRAY_STRING_SEGMENTS
internal\c/../temp/global.txt:81:11: note: '__ARRAY_STRING_SEGMENTS' declared here
81 | ptrszint *__ARRAY_STRING_SEGMENTS=NULL;
| ^
In file included from internal\c/qbx.cpp:1742:
internal\c/../temp/main.txt:29574:181: warning: implicit conversion from 'int' to 'uint8_t' (aka 'unsigned char') changes value from 256 to 0 [-Wconstant-conversion]
29574 | *(uint8*)(((char*)_FUNC_ICONPREVIEW_ARRAY_UDT_ENTRY[0])+((array_check((*_FUNC_ICONPREVIEW_LONG_I)-_FUNC_ICONPREVIEW_ARRAY_UDT_ENTRY[4],_FUNC_ICONPREVIEW_ARRAY_UDT_ENTRY[5]))*16))= 256 ;
| ~ ^~~
1 warning and 19 errors generated.
mingw32-make: *** [Makefile:413: internal\c/qbx.o] Error 1
Obviously, it must be an error to redim a string array with a fixed length after it was DIM'ed without a fixed length. If this is the proper behavior, the wiki doesn't indicate it. What is interesting is that the IDE didn't flag the error.
Thoughts?
It's not the having, it's the doing.