error: expected ';' before '(' token

Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
Post Reply
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

error: expected ';' before '(' token

Post by ndudman »

Hi

I'm getting the following internal error, the test case is provided below.
  • test28_9_09.c:71: error: expected ';' before '(' token
    test28_9_09.c:71: error: expected ';' before '}' token
    test28_9_09.c:71: error: expected statement before ')' token
    test28_9_09.c:75: error: expected ')' before 'else'
    test28_9_09.c:82: error: expected ';' before '}' token
    test28_9_09.c:104: error: expected declaration or statement at end of input
    test28_9_09.c:97: warning: unused variable 'stringTbl'
    Error: one or more errors occurred in the back-end build process for "test28-9-09.zxb"
    >Exit code: 1

Code: Select all

Declare Sub wait4userInput(byVal str as String) Based wait4userInputAddr
private wait4userInputAddr as Long Attribute(used)
public waiting4UserInput as byte = 0

'~ Called from Menu_imp.c menu definition
public sub SetTime() Attribute(Used)
	'~ Procedure for getting key input	
	waiting4UserInput = 1

	'~ 2) register the call back routine
	wait4userInputAddr = SetTimeDOIT.CodeAddress
	'~ call displayMsg("FMT HH:MM")	
	'~ call DisplaySetPos(1, 5)
end sub

dim kbReadTask(1 to 260) as Byte

Dim keyVal as UnsignedInteger	
Dim keyStr as String
Dim inputStr as String
sub kbRead()
		do
			'~ keyVal = kb_get()
			'~ KeyStr = Chr(kb_decode(keyVal, 0))
			KeyStr = "f"
		
			'~ if (menuActive = 1) then
				'~ if (waiting4UserInput = 1) then	
					select case keyVal
						case 0 'We have finished, passed keys to waiting sub
							Call wait4userInput(inputStr)	
							waiting4UserInput = 0
							inputStr = ""															
						case else 
							if &#40;Asc&#40;keyStr&#41; <> 0&#41; then
								inputStr = inputStr & keyStr
								'~ call showUserKey&#40;keyStr&#41;
								'~ call showUserKey&#40;inputStr&#41;
							end if
						end select												
				'~ end if			
			'~ end if
			call delay&#40;0.3&#41;
		loop
end sub

sub SetTimeDOIT&#40;Byval s as String&#41;	
end sub

Sub Main&#40;&#41;	
	callTask kbRead&#40;&#41;, kbReadTask	
end sub
project file is

Code: Select all

--verbose
--keep-files
test28-9-09.bas
The generated c file test28-9-09.c is

Code: Select all

#include "test28_9_09.h"

#define HEAP_LIMIT			&#40;uint8_t *&#41;0
#define HEAP_SIZE			512

PersistData sysData EEMEM = &#123; 0, ZX_TRUE &#125;;

// default Com1 speed
#define DEF_COM1_SPEED		19200

// transmit and receive queues for Com1
uint8_t txQueue&#91;25&#93; NO_INIT;
uint8_t rxQueue&#91;50&#93; NO_INIT;

static int32_t mzv_wait4userInputAddr USED;
static uint8_t mzv_kbReadTask&#91;260&#93;;
static uint16_t mzv_keyVal;
static String mzv_keyStr;
static String mzv_inputStr;

uint8_t zv_waiting4UserInput;

ZX_INIT_MAIN&#40;init_test28_9_09, HEAP_LIMIT, HEAP_SIZE&#41;
&#123;
	initHeap&#40;&#41;;
	initQueue&#40;&#40;Queue *&#41;txQueue, sizeof&#40;txQueue&#41;&#41;;
	initQueue&#40;&#40;Queue *&#41;rxQueue, sizeof&#40;rxQueue&#41;&#41;;
	zxInit&#40;BAUD_FACTOR_2X&#40;DEF_COM1_SPEED&#41;&#41;;
#if defined&#40;ENABLE_SW_UART&#41;
	enableSerialSW&#40;&#41;;
#endif
	strInit&#40;&mzv_keyStr, AN_STR&#41;;
	strInit&#40;&mzv_inputStr, AN_STR&#41;;
&#125;

int
main&#40;void&#41;
&#123;
#if defined&#40;ZX_INIT&#41;
	ZX_INIT;
#endif
	startMainTask&#40;zf_Main&#41;;
	for&#40;;;&#41;;
&#125;

void
zf_Main&#40;void&#41;
&#123;
	taskStart&#40;zf_kbRead, mzv_kbReadTask, 260, 0&#41;;
&#125;

void
zf_SetTime&#40;void&#41;
&#123;
	zv_waiting4UserInput = 1;
	mzv_wait4userInputAddr = flashAddr&#40;&zf_SetTimeDOIT&#41;;
&#125;

void
zf_kbRead&#40;void&#41;
&#123;
	while &#40;1&#41;
	&#123;
		strCopy&#40;&mzv_keyStr, STRTBL&#40;0&#41;&#41;;
		&#123;
			uint16_t _zv_selectValTemp02;

			_zv_selectValTemp02 = mzv_keyVal;
			if &#40;_zv_selectValTemp02 == 0&#41;
			&#123;
				IC0&#40;&#40;void &#40;*&#41;&#40;String&#41;&#41;&#40;uint16_t&#41;&#40;mzv_wait4userInputAddr&#41;, mzv_inputStr&#41;;
				zv_waiting4UserInput = 0;
				strCopy&#40;&mzv_inputStr, STRTBL&#40;2&#41;&#41;;
			&#125;
			else
			&#123;
				if &#40;&#40;strChar&#40;mzv_keyStr, 1&#41;&#41;&#41;
				&#123;
					strCopy&#40;&mzv_inputStr, strCat&#40;mzv_inputStr, mzv_keyStr&#41;&#41;;
				&#125;
			&#125;
		&#125;
		taskDelay&#40;0.3&#41;;
	&#125;
&#125;

void
zf_SetTimeDOIT&#40;String zp_s&#41;
&#123;
	uint8_t strTypeSave1;
	FIX_PARM_STR&#40;strTypeSave1, zp_s&#41;;

	FREE_PARM_STR&#40;strTypeSave1, zp_s&#41;;
&#125;

// string table
prog_char stringTbl&#91;&#93; =
&#123;
	// STRTBL&#40;0&#41; - "f"
	0x01, 0x66, 

	// STRTBL&#40;2&#41; - ""
	0x00, 
&#125;;
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

Thanks. Now Don has something to debug with.

It looks like the code generation for the C function call with parameters is putting the closing ')' in the wrong place. It should be after the parameters, not after the function name.

I have not found a need for based procedures before. Any reason for making it based?
Mike Perks
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

Thanks

Using based procedures _ I like to try everything out :)... but really I have an LCD and keyboard interface, data can be set via the keyboard at different points within a menu or data display screens, validation is triggered via a generic ENTER key handler which calls back to the registered handler for user input which is set up when the user was initially prompted for question, data, y/n, etc.

A GOOD question, I had to go back and look at the code and see how it worked :)

Neil
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

ndudman wrote:I'm getting the following internal error...
What version of the compiler are you using? I can reproduce the error with the current release v2.8.7. However, the experimental version v2.8.9 compiles your test case without a problem (other than a warning about indeterminate task stack size).

http://www.zbasic.net/download/ZBasic/2 ... _2-8-9.zip
- Don Kinzer
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

I was using the latest stable From webpages which I downloaded about 2 days ago.

Will give the new experimental one a try.

Thanks
Neil
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

Thanks

My test case now compiles.

Not sure if its related, as I've not seen this before, I get
  • avr-gcc -c -DF_CPU=14745600UL -Dzx24n -mmcu=atmega644p -I"C:/Program Files/ZBasic/zxlib" -I. -gdwarf-2 -Os -Wall -funsigned-char -fpack-struct -Wstrict-prototypes -std=gnu99 -fgnu89-inline I:/source/swapper/ntc_convert.c -o I:/source/swapper/ntc_convert.o
    avr-gcc -c -o
    avr-gcc: argument to '-o' is missing
I wanted to look at the generated make file... I tried the undocumented --diag=x100 which was mentioned about a year ago... but perhaps this is different now, I can't find the make file to see closer to understanding what the problem is.

Thanks
Neil
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

I found the make file, its a bat file
  • @echo off
    set TARG_BASE=swapper
    set TARGET=swapper.bin
    set MCU=atmega644p
    set F_CPU=14745600
    set DEVICE=zx24n
    set ZXLIBDIR=C:/Program Files/ZBasic/zxlib
    set ZXLIB=%DEVICE%
    set LDSCRIPT=%ZXLIBDIR%/zx_avr5.lds
    set BFLAGS=-D%DEVICE% -mmcu=%MCU% -I"%ZXLIBDIR%" -I.
    set FLAGS=-DF_CPU=%F_CPU%UL %BFLAGS% -gdwarf-2 -Os -Wall -funsigned-char -fpack-struct
    set CFLAGS=%FLAGS% -Wstrict-prototypes -std=gnu99 -fgnu89-inline
    set LDFLAGS=-mmcu=%MCU% -L"%ZXLIBDIR%" -Wl,-T,"%LDSCRIPT%"
    set LDFLAGS=%LDFLAGS% -u rtc_ISR
    set LDFLAGS=%LDFLAGS% -u int0_ISR
    set LDFLAGS=%LDFLAGS% -u int1_ISR
    set LDFLAGS=%LDFLAGS% -u int2_ISR
    set LDFLAGS=%LDFLAGS% -u pcint0_ISR
    set LDFLAGS=%LDFLAGS% -u pcint1_ISR
    set LDFLAGS=%LDFLAGS% -u pcint2_ISR
    set LDFLAGS=%LDFLAGS% -u pcint3_ISR
    set LDFLAGS=%LDFLAGS% -u anaComp_ISR
    set LDFLAGS=%LDFLAGS% -u default_ISR
    set LDLIBS=-l%ZXLIB% -lm
    set CC=avr-gcc
    set AR=avr-ar
    set OBJCOPY=avr-objcopy
    set NM=avr-nm
    set OBJDUMP=avr-objdump
    set ECHO=echo
    set REMOVE=rm -f
    set IFILE=%TARG_BASE%.i1
    set EXTOBJ=
    set ERRCODE=0
    set OBJ=sensors.o LedFlasher.o LCD_4P.o MAX6957.o MAX1202.o guicmd.o myTime.o debug.o Glabals.o DS1305.o swapper.o relay.o I:/source/swapper/ntc_convert.o I:/source/swapper/keyboard.o I:/source/swapper/keymap_hd44780_en.o I:/source/swapper/Menu.o

    cd "zxTempDir\swapper"

    set CMD=%CC% -c %CFLAGS% sensors.c -o sensors.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% LedFlasher.c -o LedFlasher.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% LCD_4P.c -o LCD_4P.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% MAX6957.c -o MAX6957.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% MAX1202.c -o MAX1202.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% guicmd.c -o guicmd.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% myTime.c -o myTime.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% debug.c -o debug.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% Glabals.c -o Glabals.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% DS1305.c -o DS1305.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% swapper.c -o swapper.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% relay.c -o relay.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% I:/source/swapper/ntc_convert.c -o I:/source/swapper/ntc_convert.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% I:/source/swapper/keyboard.c -o I:/source/swapper/keyboard.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% I:/source/swapper/keymap_hd44780_en.c -o I:/source/swapper/keymap_hd44780_en.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %CFLAGS% I:/source/swapper/Menu.c -o I:/source/swapper/Menu.o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %AFLAGS% -o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %AFLAGS% -o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %AFLAGS% -o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -c %AFLAGS% -o
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error

    set CMD=%CC% -o %IFILE% %LDFLAGS% %OBJ% %EXTOBJ% %LDLIBS%
    echo %CMD%
    %CMD%
    if ERRORLEVEL 1 goto error
    %OBJCOPY% -R .eeprom -R .zx_eeprom -O binary %IFILE% %TARG_BASE%.bin
    if ERRORLEVEL 1 goto error
    %OBJCOPY% -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O binary %IFILE% %TARG_BASE%.eeb
    if ERRORLEVEL 1 goto error
    %NM% -n %IFILE% > %TARG_BASE%.sym
    %OBJDUMP% -h -S %IFILE% > %TARG_BASE%.lss

    goto done

    :error
    set ERRCODE=1

    :done
    %REMOVE% %IFILE% %OBJ%
    exit %ERRCODE%
I think those I:/ paths need to be quoted ? I did that to the bat file as well as added the avr-gcc to the PATH variable and it worked more, but still was missing something. There are also some blank

Any help ?

Neil[/list]
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

ndudman wrote:I found the make file, its a bat file
You're running on Linux, yes?

I see that the issue is related to assembly language files. I'll take a look at it to see why is isn't working correctly.
- Don Kinzer
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

Thanks

Thats right I'm using linux.

Neil
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

dkinzer wrote:I see that the issue is related to assembly language files.
This issue has been corrected in an experimental release of the compiler:
http://www.zbasic.net/download/ZBasic/2 ... 2-8-10.zip
- Don Kinzer
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

Thanks

I have it compiling now

Neil
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

Hi

With the experiemental version there seems to be a problem with initialised variables, following code, dosn't print 1.0 on the experiemental version (Version 2.8.10)
, but does on my older version (. Version 2.6.12, which I had from when I was last working on the project in the spring)

Code: Select all

private lcdUpdateInterval as Single = 1.0 ' in seconds, to update LCD

Sub Main&#40;&#41;

	Debug.print "debug lcdUpdateInterval=" ; lcdUpdateInterval
End Sub
Thanks
Neil
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

ndudman wrote:With the experiemental version there seems to be a problem with initialised variables
Thank you for supplying a concise test case. We have confirmed the issue, determined its cause and formulated a solution. Further testing is needed to confirm its efficacy.
- Don Kinzer
Post Reply