1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

compile /runtime error with #include file in include dir

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.

compile /runtime error with #include file in include dir

Postby doc-helmut » 27 Nov 2010, 22:16

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[i],
#----------------------------------------------------------
# Error: Unknown datatype
File "c:\Temp\temp.nxc" ; line 11
#


what's wrong?
Last edited by doc-helmut on 28 Nov 2010, 16:36, edited 1 time in total.
regards,
HaWe
±≠≈αγδεωΔΦΣ∫√∅∞
NXC CHESS for NXT: http://www.mindstormsforum.de/viewtopic.php?f=70&t=6790
indispensable for NXC + EV3-C: easy + trouble-free network & sensor+motor remote control for rs485, BT, USB!
User avatar
doc-helmut
 
Posts: 2425
Joined: 29 Sep 2010, 14:25

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

Postby doc-helmut » 28 Nov 2010, 10:45

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}
regards,
HaWe
±≠≈αγδεωΔΦΣ∫√∅∞
NXC CHESS for NXT: http://www.mindstormsforum.de/viewtopic.php?f=70&t=6790
indispensable for NXC + EV3-C: easy + trouble-free network & sensor+motor remote control for rs485, BT, USB!
User avatar
doc-helmut
 
Posts: 2425
Joined: 29 Sep 2010, 14:25

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

Postby afanofosc » 29 Nov 2010, 21:31

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/
User avatar
afanofosc
Site Admin
 
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN


Return to Mindstorms Software

Who is online

Users browsing this forum: No registered users and 1 guest