"Error compiling for board Teensy LC"

tjm56

Member
I'm not sure what happened - i had this program working fine previously but all of a sudden it started acting up and wont compile on the teensy LC anymore. any ideas on how to resolve this issue? heres the full error message:

Code:
Arduino: 1.8.5 (Mac OS X), TD: 1.40, Board: "Teensy LC, MIDI, 48 MHz, Debug, US English"


/Users/user/Desktop/project/tap_tempo.ino: At global scope:
/Users/user/Desktop/project/tap_tempo.ino:32:1: internal compiler error: in output_constructor_regular_field, at varasm.c:4986
 }
 ^
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Multiple libraries were found for "LiquidCrystal.h"
 Used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/LiquidCrystal
 Not used: /Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal
Error compiling for board Teensy LC.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I had this project working fine yesterday and now that its stopped working i am beyond frustrated. any help would be greatly appreciated
 
Oh, that looks bad. Real compiler bugs are rare, but they do exists. :(

Since it's on line 4986, I'm going to guess you have a *lot* of code in this project or a library? Even if you posted such a huge program, I'm not sure anyone could really dig through so much code.

As will all these sorts of things, the first step is trying to whittle it down to a smaller program which still produces the error. Sorry, there's just not much I can do on this, other than this overly obvious and probably not too helpful suggestion.
 
i cut down my code to a fraction of the length and its still saying that its on 4896, there arent that many lines in the current code. Where should I go from here?
 
The problem is the incorrect way in which you initialized the pitch and step1 arrays (the compiler spits out a lot of warning messages).
E.g.
Code:
char*pitch[] = {

pitch[0] = "-12",
pitch[1] = "-11",
pitch[2] = "-10",
and
Code:
float step1[] = {
step1[0] = 1, //12
step1[1] = 10, //11
step1[2] = 18,  //10

Change the declarations of these arrays to:
Code:
const char*pitch[] = {

  "-12",
  "-11",
  "-10",
  "-9 ",
  "-8 ",
  "-7 ",
  "-6 ",
  "-5 ",
  "-4 ",
  "-3 ",
  "-2 ",
  "-1 ",
  " 0 ",
  "+1 ",
  "+2 ",
  "+3 ",
  "+4 ",
  "+5 ",
  "+6 ",
  "+7 ",
  "+8 ",
  "+9 ",
  "+10",
  "+11",
  "+12"
};

float step1[] = {
   1, //12
  10, //11
  18,  //10
  28,  //9
  38, //8
  47, //7
  54, //6
  60, //5
  69, //4
  77, //3
  85, //2
  90,//1
  99, //0
  107, //1
  117,//2
  124,//3
  130,//4
  140,//5
  150,//6
  157,//7
  165,//8
  171,//9
  179,//10
  189,//11
  200//12
};

This gets rid of the problem.
Adding const to the declaration of the pitch array removes a lot more compiler warning messages which then makes it easier to see warnings like this:
Code:
lcd_update: In function 'void lcdUpdate()':
lcd_update:15: warning: array subscript is above array bounds 
     lcd.write(dash[8]);  

              ^

AARP_v2: In function 'void loop()':
AARP_v2:485: warning: array subscript is above array bounds 
     lcd.write(dash[8]);

              ^

AARP_v2:491: warning: array subscript is above array bounds 
     lcd.write(dash[8]);
These suggest that there's an error here.
EDIT: They should probably be
Code:
     lcd.write(dash);

Pete
 
Last edited:
Thanks Pete- I’ll give that a shot. wonder why it has compiled hundreds of times in the past, yet all of a sudden won’t compile?
 
Indeed, the error is wrong syntax for initializing the pitch[] and step1[] arrays.

wonder why it has compiled hundreds of times in the past, yet all of a sudden won’t compile?

I believe a better question is why did that ever compile before? Are you sure it was really like that in a prior version? Any chance you have any backups or prior versions archived anywhere?
 
Looks like older 4.8 versions of the toolchain do allow this syntax. But 5.4 we're using doesn't like it at all.

It is what is called a designated initializer. The C99 standard describes a syntax to initialize fields within a structure, and GCC had a slightly different syntax as a previous GCC extension. GCC accepts both formats when translating the C language. However the C++ language committee decided they did not want it, and it is not in the ISC C++. I don't recall if older GNU C++'s accepted designated initializers or not. Perhaps if the code was in a library, it was installed as a C file and not C++, and the C compiler allowed it.
 
yeah I have a few that are works in progress, using the same incorrect syntax, and it doesnt compile. Also, I changed the syntax to "const char*pitch[]" and it still wont compile.

I did update my teensyduino software recently, should I revert to an older version?
 
yup, solved the problem. reverted back to teensyduino 1.35 and arduino 1.8.1 and its uploading. Thank you all for your help and suggestions!
 
You could also just edit the initialization of those 2 arrays. Assigning to the array within its own initialization can't be good...
 
Back
Top