Skip to content

Generated prototypes are added after global variable declarations #85

Open
@per1234

Description

@per1234

Using Arduino IDE 1.6.8 2015/12/28 12:34 with Windows 7 64 bit
Generated prototypes are added after global variable declarations which causes error when the global variable initialization calls a function.

byte x = one();

byte one() {
  return 1;
}

void setup() {}
void loop() {}

Compiler error: 'one' was not declared in this scope

Generated code:

#include <Arduino.h>
#line 1
#line 1 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_ada7ab83d38e9f542377ce1f8da0ce54\\sketch_dec29a.ino"
byte x = one();

#line 3 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_ada7ab83d38e9f542377ce1f8da0ce54\\sketch_dec29a.ino"
byte one();
#line 7 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_ada7ab83d38e9f542377ce1f8da0ce54\\sketch_dec29a.ino"
void setup();
#line 8 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_ada7ab83d38e9f542377ce1f8da0ce54\\sketch_dec29a.ino"
void loop();
#line 3
byte one() {
  return 1;
}

void setup() {}
void loop() {}

This compiles fine in Arduino IDE 1.6.5r5 and works in 1.6.6 and up if the function prototype is manually added.

Originally reported at http://forum.arduino.cc/index.php?topic=366573.msg2540168#msg2540168

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions