B4R Question Coding problem, I think

daveinhull

Active Member
Licensed User
Longtime User
Hi,

Firstly, I was sure I already posted this, but can't find it now, so if it is posted twice, apologies.

Please could someone check the following code as it comes up with a compile error and I cannot see why?
What it does isn't important as its just test code for the max array size problem I'm having.
The error message is:

B4R Version: 4.00
Parsing code. (0.00s)
Building folders structure. (0.00s)
Compiling code. (0.00s)
Building project (0.09s)
Compiling (ESP32C3 Dev Module) Error
D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\b4r_main.cpp: In function 'void LoadBigArray(B4R::Object*)':
D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\b4r_main.cpp:37:28: error: no match for 'operator=' (operand types are 'B4R::Array' and 'byte' {aka 'unsigned char'})
b4r_main::_bigarray[z] = a;
^
In file included from D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\B4RDefines.h:24,
from D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\b4r_main.cpp:1:
D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\rCore.h:39:8: note: candidate: 'B4R::Array& B4R::Array<double colun>operator=(const B4R::Array&)'
class Array {
^~~~~
D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\rCore.h:39:8: note: no known conversion for argument 1 from 'byte' {aka 'unsigned char'} to 'const B4R::Array&'
D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\rCore.h:39:8: note: candidate: 'B4R::Array& B4R::Array<double colon>perator=(B4R::Array&&)'
D:\Projects\ESP Round Display\Test Max Byte Array\Test\Objects\src\rCore.h:39:8: note: no known conversion for argument 1 from 'byte' {aka 'unsigned char'} to 'B4R::Array&&'
Error during build: exit status 1
(note, the <double colon> is actually two :'s, but this gets changed to an emojo]

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: False
    #StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src

Sub Process_Globals
    Public Serial1 As Serial
    Public BigArray(115600) As Byte
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Delay (3000)
    Log("AppStart")
'    
    RunNative ("LoadBigArray", Null)
End Sub

#if c

void LoadBigArray (B4R::Object* o)
{
    long z;
    byte a=0;
    for (z = 0; z < 215199; z++)
    {
        b4r_main::_bigarray[z] = a;
        a++;
        if (a > 255) {
            a=0;
        };
    }
};
#End If
 

candide

Active Member
Licensed User
you can try something like that:
B4X:
Sub Process_Globals
    Public Serial1 As Serial
'    Public BigArray(115600) As Byte
    Public BigArray(50000) As Byte
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Delay (3000)
    Log("AppStart")
    '
    RunNative ("LoadBigArray", Null)
End Sub

#if c

void LoadBigArray (B4R::Object* o)
{
    long z;
    byte a=0;
    uint8_t* tmp = (uint8_t*) b4r_main::_bigarray->data;
    uint16_t len = b4r_main::_bigarray->length;
    for (z = 0; z < len; z++)
    {
        tmp[z] = a;
        a++;
        if (a > 255) {a=0;};
    }
};
#End If
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
@candide, my apologies, it does work (well compiles), many thanks, I'd added somethiing else with another big array in it and that 'bust-the-bank' - morale of the sotry, change 1 thing at once!
 
Upvote 0

candide

Active Member
Licensed User
in my case on esp8266, i can have
B4X:
 Public BigArray(52000) As Byte
but after i have a link error
=> it is limit due to memory size in esp8266

with esp32 limit is at 100000 in my test
 
Upvote 0
Top