View unanswered posts | View active topics It is currently Tue Sep 22, 2020 8:08 am

Reply to topic  [ 3 posts ] 
local static variable problem 
Author Message

Joined: Wed Nov 14, 2012 4:22 am
Posts: 2
Post local static variable problem
void test()
//if (1==1)
static int a = 0;
writeDebugStream("a= %d\n",a);

task main()
}and will output:

produces the output

a= 1
a= 1
a= 1

where as it should be

a= 1
a= 2
a= 3

if the inner braces are removed it works properly.

this happens on both 3.54 and 3.55 beta, on vex

Wed Jan 16, 2013 5:57 am
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: local static variable problem
Yes, this is a known problem. I have reported it to the RobotC folks. Static variables is supposed to be initialized only once during compile time. It looks like RobotC actually generated code to initialize it at run-time.

Wed Jan 16, 2013 7:54 am
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: local static variable problem
Thank you for the heads up on this one, we now have a BETA build (ROBOTC 3.59.0) that should fix this problem (link below). As with any BETA build, there may be unforeseen issues or bugs, and we ask that you please report any that you find either here in our Issues and Bugs forum or directly to us via Thank you in advance!

ROBOTC BETA 3.59.0 Download

Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Mon Feb 25, 2013 12:00 pm
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.