compile /runtime error with #include file in include dir

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

compile /runtime error with #include file in include dir

Post by HaWe »

hi, I get this strange behavior (using Bricxcc 3.3.8.8, no test_release installed):

I have a header file nxcio.h

Code: Select all

int LCDline[8]={56,48,40,32,24,16,8,0};

#define printf2( _x, _y, _format1, _format2, _value1, _value2) { \
  string sval1 = FormatNum(_format1, _value1); \
  string sval2 = FormatNum(_format2, _value2); \
  string s =sval1+sval2; \
  TextOut(_x, _y, s); \
}
in the directory
G:\Akten\Programmierung\NXC\include
(this path is set in preferences as include path)

and a test file

Code: Select all

#include "nxcio.h"
task main(){

  for (int i=0;i<8;i++) {
     printf2(0,LCDline[i],"%3d","%3d", i, (i+2)&14);
  }
  while (true);
}
in the directory
G:\Akten\Programmierung\NXC\Test

If I press F5 I get no error,

but if I press ctrl+F5 I get the error
# Error: Undefined Identifier LCDline
File "c:\Temp\temp.nxc" ; line 10
# TextOut(0, LCDline[
#----------------------------------------------------------
# Error: Unknown datatype
File "c:\Temp\temp.nxc" ; line 10
# TextOut(0, LCDline,
#----------------------------------------------------------
# Error: Unknown datatype
File "c:\Temp\temp.nxc" ; line 11
#


what's wrong?
Last edited by HaWe on 28 Nov 2010, 16:36, edited 1 time in total.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: strange compile error with #include file in include dir

Post by HaWe »

seemed to be a Bricxcc compiler bug...

so I meanwhile copied the testrelease 20101103 into the Bricxc folder.
Now I don't get the compile error,
the program starts,
but all values (at least only the last values) are written into line 0 (bottom line)
(that means, the single values of LCDline[] are ignored)


EDIT:
resolved!

my mistake was:

Code: Select all

int LCDline[8]={56,48,40,32,24,16,8,0};
instead of

Code: Select all

int LCDline[]={56,48,40,32,24,16,8,0}
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: compile /runtime error with #include file in include dir

Post by afanofosc »

There was a bug fix made in the compiler a while back that changed how global variables are initialized which might explain the behavior you are seeing. I should probably have the compiler either ignore the size when you provide an initializer array or have it both initialize to the specified size and then re-init with the provided initializer or something really smart like that. It sounds like right now it defines the array in the static dataspace but then initializes it with zeros to the specified length in the global initialization subroutine that gets inserted into task main by the compiler.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest