slviajero / tinybasic

A BASIC interpreter for Arduino, ESP, RP2040, STM32, Infineon XMC and POSIX with IoT and microcontroller features.
GNU General Public License v3.0
203 stars 31 forks source link

error: void value not ignored as it ought to be #62

Open Suresh-Subedi opened 6 months ago

Suresh-Subedi commented 6 months ago

I am trying to build this basic for arduino uno using platformio. I copied all .ino code to main.cpp. I copied other files in the same src folder with same names. I also added #include to all the files. When I compile I encounter following two errors and compilation fails. What could be causing this?

src\main.cpp: In function 'number_t getvar(mem_t, mem_t)': src\main.cpp:1100:30: warning: invalid conversion from 'mem_t ()(address_t) {aka signed char ()(unsigned int)}' to 'mem_t {aka signed char}' [-fpermissive]
return getnumber(a, memread2); ^ In file included from src\main.cpp:37:0: src\basic.h:437:6: note: initializing argument 2 of 'void getnumber(address_t, mem_t)' void getnumber(address_t, mem_t); ^~~~~

src\main.cpp:1100:30: error: void value not ignored as it ought to be

return getnumber(a, memread2); ^ src\main.cpp: In function 'void setvar(mem_t, mem_t, number_t)': src\main.cpp:1167:27: warning: invalid conversion from 'void ()(address_t, mem_t) {aka void ()(unsigned int, signed char)}' to 'mem_t {aka signed char}' [-fpermissive] setnumber(a, memwrite2, v); ^

src\main.cpp:1167:27: error: too many arguments to function 'void setnumber(address_t, mem_t)'

In file included from src\main.cpp:37:0:

slviajero commented 6 months ago

This looks like the header and the interpreter file don't fit together in the repo. I changed the entire getnumber and setnumber logic. Looks like I checked in an inconsistent state. I will check this tonight.

slviajero commented 6 months ago

Please try to use basic.h from the Posix folder in the meantime. This should be ok.

Suresh-Subedi commented 6 months ago

I am gettings another error when I use basic.h from Posix folder. I also copied basic.c as it doesn't exist in IotBasic.

src\basic.c: At top level: src\basic.c:2322:5: error: conflicting types for 'innumber' int innumber(number_t r, char buffer, address_t k) { ^~~~ In file included from src\basic.c:35:0: src\basic.h:517:6: note: previous declaration of 'innumber' was here char innumber(number_t,char); ^~~~ src\basic.c: In function 'parsestringvar':

Suresh-Subedi commented 6 months ago

If I chage return value to char and add address_t to signature in header, I get:

src\main.cpp:2326:5: error: ambiguating new declaration of 'int innumber(number_t, char, address_t)' int innumber(number_t r, char buffer, address_t k) { ^~~~ In file included from src\main.cpp:37:0: src\basic.h:517:6: note: old declaration 'char innumber(number_t, char, address_t)' char innumber(number_t,char,address_t); ^~~~ src\main.cpp: In function 'void outnumber(number_t)':

slviajero commented 6 months ago

Ok, let me check tonight. I will check in a consistent state. In my local dev environment it works cool.

On 26. Feb 2024, at 14:30, Suresh Subedi @.***> wrote:

I am gettings another error when I use basic.h from Posix folder. I also copied basic.c as it doesn't exist in IotBasic.

src\basic.c: At top level: src\basic.c:2322:5: error: conflicting types for 'innumber' int innumber(number_t r, char buffer, address_t k) { ^~~~ In file included from src\basic.c:35:0: src\basic.h:517:6: note: previous declaration of 'innumber' was here char innumber(number_t,char); ^~~~ src\basic.c: In function 'parsestringvar':

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/62#issuecomment-1964152317, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56F443NVBBO3R6RXWITYVSE65AVCNFSM6AAAAABDZWR6PGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGE2TEMZRG4. You are receiving this because you commented.

slviajero commented 6 months ago

I fixed this now. basic.h and IotBasic.ino are consistent again. Sorry for the mistake. I change a lot in the types and data structure right now in the 2.0alpha version. In about 2 weeks 2.0 will got beta and be stable again.

On 26. Feb 2024, at 14:36, Suresh Subedi @.***> wrote:

If I chage return value to char and add address_t to signature in header, I get:

src\main.cpp:2326:5: error: ambiguating new declaration of 'int innumber(number_t, char, address_t)' int innumber(number_t r, char buffer, address_t k) { ^~~~ In file included from src\main.cpp:37:0: src\basic.h:517:6: note: old declaration 'char innumber(number_t, char, address_t)' char innumber(number_t,char,address_t); ^~~~ src\main.cpp: In function 'void outnumber(number_t)':

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/62#issuecomment-1964166432, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56D6NBSUQXQO3RNERD3YVSFXLAVCNFSM6AAAAABDZWR6PGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGE3DMNBTGI. You are receiving this because you commented.

Suresh-Subedi commented 6 months ago

Thank you. Unfortunately I still have some errors:

src\main.cpp:1273:30: error: void value not ignored as it ought to be

return getnumber(a, memread2); ^ src\main.cpp: In function 'void setvar(mem_t, mem_t, number_t)': src\main.cpp:1348:27: warning: invalid conversion from 'void ()(address_t, mem_t) {aka void ()(unsigned int, signed char)}' to 'mem_t {aka signed char}' [-fpermissive] setnumber(a, memwrite2, v); ^

src\main.cpp:1348:27: error: too many arguments to function 'void setnumber(address_t, mem_t)'

In file included from src\main.cpp:35:0: src\basic.h:436:6: note: declared here void setnumber(address_t, mem_t); ^~~~~ src\main.cpp: In function 'address_t createarray(mem_t, mem_t, address_t, address_t)':

Suresh-Subedi commented 6 months ago

I am using basic.h from IotBasic again. Should I still use basic.h from Posix?

slviajero commented 6 months ago

is identicalSent from my iPhoneOn Feb 27, 2024, at 1:01 PM, Suresh Subedi @.***> wrote: I am using basic.h from IotBasic again. Should I still use basic.h from Posix?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

slviajero commented 6 months ago

but best use both files from IoTBasic. I have tested this file set.Sent from my iPhoneOn Feb 27, 2024, at 1:01 PM, Suresh Subedi @.***> wrote: I am using basic.h from IotBasic again. Should I still use basic.h from Posix?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

Suresh-Subedi commented 6 months ago

I cloned your repo. Downloaded and installed Arduino IDE and compiled repo in it. It compiled fine. PlatformIO is a bit more quirky and requires methods to be declared before they are used.

src\main.cpp:1348:27: error: too many arguments to function 'void setnumber(address_t, mem_t)' In file included from src\main.cpp:35:0: src\basic.h:436:6: note: declared here void setnumber(address_t, mem_t); ^~~~~ src\main.cpp: In function 'address_t createarray(mem_t, mem_t, address_t, address_t)':

I solved this error by placing void setnumber(address_t m, memwriter_t f, number_t v); after includes in main.cpp (IotBasic.ino).

src\main.cpp:1273:30: error: void value not ignored as it ought to be return getnumber(a, memread2); ^ src\main.cpp: In function 'void setvar(mem_t, mem_t, number_t)': src\main.cpp:1348:27: warning: invalid conversion from 'void ()(address_t, mem_t) {aka void ()(unsigned int, signed char)}' to 'mem_t {aka signed char}' [-fpermissive] setnumber(a, memwrite2, v); ^

While investigating this, I saw that method signature of getnumber doesn't match in basic.h (void getnumber(address_t, mem_t);) and IotBasic.ino (number_t getnumber(address_t m, memreader_t f) {...}). I got further by updating getnumber in basic.h to return number_t. Still encountering other issues though when linking: collect2.exe: error: ld returned 1 exit status.

slviajero commented 6 months ago

Ok! Absolutely correct. These were still the wrong prototypes. My apologies. I now checked in the corrected version.

Background info: I changed the entire mem access code and I am still rewriting. I always test first on the Posix code. So this is a remnant of this process.

On 28. Feb 2024, at 15:21, Suresh Subedi @. @.>> wrote:

I cloned your repo. Downloaded and installed Arduino IDE and compiled repo in it. It compiled fine. PlatformIO is a bit more quirky and requires methods to be declared before they are used.

src\main.cpp:1348:27: error: too many arguments to function 'void setnumber(address_t, mem_t)' In file included from src\main.cpp:35:0: src\basic.h:436:6: note: declared here void setnumber(address_t, mem_t); ^~~~~ src\main.cpp: In function 'address_t createarray(mem_t, mem_t, address_t, address_t)':

I solved this error by placing void setnumber(address_t m, memwriter_t f, number_t v); after imports in main.cpp (IotBasic.ino).

src\main.cpp:1348:27: error: too many arguments to function 'void setnumber(address_t, mem_t)' In file included from src\main.cpp:35:0: src\basic.h:436:6: note: declared here void setnumber(address_t, mem_t); ^~~~~ src\main.cpp: In function 'address_t createarray(mem_t, mem_t, address_t, address_t)':

While investigating this, I saw that method signature of getnumber doesn't match in basic.h (void getnumber(address_t, mem_t);) and IotBasic.ino (number_t getnumber(address_t m, memreader_t f) {...}). I got further by updating getnumber in basic.h to return number_t. Still encountering other issues though when linking: collect2.exe: error: ld returned 1 exit status.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/62#issuecomment-1969088042, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56DQFV3HVNZNXWAIRUTYV44P7AVCNFSM6AAAAABDZWR6PGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRZGA4DQMBUGI. You are receiving this because you commented.