Page 1 of 1

Problem with Attribute(Used)

Posted: 12 January 2009, 14:44 PM
by ndudman
Hi

With the code below... I can't get to compile because of the way the if () block is created in c file... I think I saw this refered to when I first was looking through posts but can't find it again. The generated c code is shown below also.

Code: Select all

public menuActive		as byte 

public sub showDataLCD() Attribute(Used)
	do
		Dim a as Integer Attribute(used)
		Dim b as Integer Attribute(used)
		a = CInt(menuActive )
		b = 2

		if &#40; a < b &#41; then
			delay&#40;2.1&#41;
		end if
		delay&#40;1.0&#41;
	loop
end sub

sub main&#40;&#41;
	menuActive = 1
end sub
  • est10.c:50: warning: 'used' attribute ignored
    test10.c:51: warning: 'used' attribute ignored
    test10.c:57: error: expected expression before ')' token
    test10.bas:10: Internal Error: no means to generate code for expression

Code: Select all

void
zf_showDataLCD&#40;void&#41;
&#123;
	&#123;
		int16_t zv_a USED;
		int16_t zv_b USED;

		while &#40;1&#41;
		&#123;
			zv_a = TYPECAST&#40;int16_t, &#40;uint8_t&#41;zv_menuActive&#41;;
			zv_b = 2;
			if &#40;&#41;
			&#123;
				taskDelay&#40;2.1&#41;;
			&#125;
			taskDelay&#40;1.0&#41;;
		&#125;
	&#125;
&#125;
p.s Is it really required if a sub is marked with attribute(used) to have to also mark variables (in this example a, b) also as used ?

Thanks
Neil

Re: Problem with Attribute(Used)

Posted: 12 January 2009, 22:07 PM
by dkinzer
ndudman wrote:I can't get to compile because of the way the if () block is created in c file.
The problem has been verified and a solution has been identified. We still have some testing to do.
ndudman wrote:Is it really required if a sub is marked with attribute(used) to have to also mark variables (in this example a, b) also as used ?
No. Procedures that are marked with the Used attribute but not referenced in ZBasic code are currently not being processed correctly. What you're seeing is an artifact of that problem.

Posted: 12 January 2009, 23:58 PM
by ndudman
Thanks for the confirmation

Regards
Neil

Re: Problem with Attribute(Used)

Posted: 13 January 2009, 13:52 PM
by dkinzer
dkinzer wrote:The problem has been verified and a solution has been identified.
There is an experimental version of the compiler that corrects this problem (available via the link below). It is not yet fully tested but the preliminary testing results look good. The experimental version also contains the correction for the structure member reference issue (also not fully tested).

http://www.zbasic.net/download/ZBasic/2 ... 2-6-12.zip