Skip to content

Non-class function prototypes are sometimes inserted inside class definition. #292

Closed
@oqibidipo

Description

@oqibidipo

A.k.a. "Hello class, I found by the road some functions that look a bit like what we alrady have. Let's throw them in."

Originally reported at http://forum.arduino.cc/index.php?topic=568492.0

Example code

class Foo {
    int blooper(int x) { return x+1; }
};

Foo foo;

void setup() {
  foo.setup();
}

void loop() {
  foo.loop();
}

With generated prototypes

#include <Arduino.h>
#line 1 "/Users/rjl/Documents/Arduino/bug_proto_1/bug_proto_1.ino"
#line 1 "/Users/rjl/Documents/Arduino/bug_proto_1/bug_proto_1.ino"
class Foo {
#line 7 "/Users/rjl/Documents/Arduino/bug_proto_1/bug_proto_1.ino"
void setup();
#line 11 "/Users/rjl/Documents/Arduino/bug_proto_1/bug_proto_1.ino"
void loop();
#line 2 "/Users/rjl/Documents/Arduino/bug_proto_1/bug_proto_1.ino"
    int blooper(int x) { return x+1; }
};

Foo foo;

void setup() {
  foo.setup();
}

void loop() {
  foo.loop();
}

This happens when the name of a function is the same as or a substring of a name of class method like loop is a substring of blooper in the example.

Tested with IDE version 1.8.7, Mac OS X 10.11.6.
OK with 1.8.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions