Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Teensyduino 1.53 Compile error on Win7

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    3

    Teensyduino 1.53 Compile error on Win7

    I am using the Arduino IDE with Teensyduino 1.53 installed on Windows 7 machine and have selected as the board "Teensy 3.2/3.1". I declare some global short x1, y1, x2, y2; and assign y1 a value.
    I get the following error(s):

    C:\Users\don\Documents\Projects\Instructable Projects\Chess_Robot\Test_Programs\IDETest_Teensy3 .1\IDETest_Teensy3.1.ino:1:11: error: 'short int y1' redeclared as different kind of symbol
    short x1, y1, x2, y2;
    ^
    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:36:0,
    from C:\Users\don\AppData\Local\Temp\arduino_build_5167 62\pch\Arduino.h:6:
    c:\program files (x86)\arduino\hardware\tools\arm\arm-none-eabi\include\math.h:539:15: note: previous declaration 'double y1(double)'
    extern double y1 _PARAMS((double));

    C:\Users\don\Documents\Projects\Instructable Projects\Chess_Robot\Test_Programs\IDETest_Teensy3 .1\IDETest_Teensy3.1.ino: In function 'void setup()':
    C:\Users\don\Documents\Projects\Instructable Projects\Chess_Robot\Test_Programs\IDETest_Teensy3 .1\IDETest_Teensy3.1.ino:5:8: error: assignment of function 'double y1(double)'
    y1 = 5;
    ^
    C:\Users\don\Documents\Projects\Instructable Projects\Chess_Robot\Test_Programs\IDETest_Teensy3 .1\IDETest_Teensy3.1.ino:5:8: error: cannot convert 'int' to 'double(double)' in assignment

    Error compiling for board Teensy 3.2 / 3.1.

    The following is the code:
    Code:
    short x1, y1, x2, y2;
    
    void setup()
    {
        y1 = 5;
    }
    
    void loop()
    {
        while(1);
        
    }
    Is this something I can fix or is there something in a library that is not properly scoped?
    Thanks, don

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,210
    y1 is already defined by the math library (y1 is the name for a Bessel function). Therefore you can not declare a global variable with this name. It is the same as you would like to declare a global variable named sin, or cos, or exp...

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,656
    Use a different name for "y1". That name is already spoken for and declared with a different type.

    With verbose compile it shows here as:
    Code:
    T:\tCode\FORUM\VarConflict\VarConflict.ino:1:11: error: 'short int y1' redeclared as different kind of symbol
     short x1, y1, x2, y2;
               ^
    In file included from T:\arduino-1.8.13\hardware\teensy\avr\cores\teensy4/WProgram.h:36:0,
                     from T:\TEMP\arduino_build_VarConflict.ino\pch\Arduino.h:6:
    t:\arduino-1.8.13\hardware\tools\arm\arm-none-eabi\include\math.h:539:15: note: previous declaration 'double y1(double)'
     extern double y1 _PARAMS((double));
                   ^
    T:\tCode\FORUM\VarConflict\VarConflict.ino: In function 'void setup()':
    T:\tCode\FORUM\VarConflict\VarConflict.ino:10:8: error: assignment of function 'double y1(double)'
         y1 = 5;
            ^
    T:\tCode\FORUM\VarConflict\VarConflict.ino:10:8: error: cannot convert 'int' to 'double(double)' in assignment

  4. #4
    Junior Member
    Join Date
    Oct 2020
    Posts
    3
    Thanks for the quick response. I was confused as this is the first time that I have used a Teensy with the Arduino IDE and when I compile the same program for an Arduino Mega, it compiles cleanly. I might have expected to have to include a math library to get that conflict. Well Thanks for the help and explanation of the error.

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,210
    I might have expected to have to include a math library to get that conflict.
    The Arduino IDE automatically includes Arduino.h. The error message defragster posted, shows that Arduino.h includes WProgram.h which includes math.h...

  6. #6
    Junior Member
    Join Date
    Oct 2020
    Posts
    3
    Ok, great, thanks for the detailed explanation. I'll just rename my variables.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •