Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Problem with Attribute(Used)

 
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode
Author Message
ndudman



Joined: 25 Dec 2008
Posts: 79

Posted: 12 January 2009, 22:44 PM    Post subject: Problem with Attribute(Used) Reply with quote

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:
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 ( a < b ) then
         delay(2.1)
      end if
      delay(1.0)
   loop
end sub

sub main()
   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:
void
zf_showDataLCD(void)
{
   {
      int16_t zv_a USED;
      int16_t zv_b USED;

      while (1)
      {
         zv_a = TYPECAST(int16_t, (uint8_t)zv_menuActive);
         zv_b = 2;
         if ()
         {
            taskDelay(2.1);
         }
         taskDelay(1.0);
      }
   }
}


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
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 13 January 2009, 6:07 AM    Post subject: Re: Problem with Attribute(Used) Reply with quote

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.
Back to top
ndudman



Joined: 25 Dec 2008
Posts: 79

Posted: 13 January 2009, 7:58 AM    Post subject: Reply with quote

Thanks for the confirmation

Regards
Neil
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 13 January 2009, 21:52 PM    Post subject: Re: Problem with Attribute(Used) Reply with quote

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.6/ZBasic_2-6-12.zip
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group