JJaneba
September 24, 2018, 9:12am
1
Hi all,
last version IDE 1.8.7 (Mac OS X) have strange behavior.
I use this code:
bool bSendValue = false;
typedef enum SIGNAL_VALUE
{
LED_OFF = 0,
LED_ON = 1
};
SIGNAL_VALUE SignalStatus;
void setup()
{
Serial.begin(115200); // init DEBUG
}
void loop()
{
SendValue();
SetSignal(LED_ON);
}
bool SendValue(void)
{
if(bSendValue)
{
}
}
void SetSignal(SIGNAL_VALUE Val)
{
SignalStatus = Val;
}
compiling result is:
enumTest:30:16: error: variable or field 'SetSignal' declared void
void SetSignal(SIGNAL_VALUE Val)
^
enumTest:30:16: error: 'SIGNAL_VALUE' was not declared in this scope
/Users/jirijaneba/Documents/Arduino/enumTest/enumTest.ino: In function 'void loop()':
enumTest:19:19: error: 'SetSignal' was not declared in this scope
SetSignal(LED_ON);
^
exit status 1
variable or field 'SetSignal' declared void
but if a I make one from this changes - all is OK:
rename function "SendValue"
OR
move declaration "bool bSendValue = false;" after enum declaration
OR
use IDE 1.8.5
Do you (anybody) know what is happen?
system
September 24, 2018, 10:00am
2
typedef enum SIGNAL_VALUE
{
LED_OFF = 0,
LED_ON = 1
};
A typedef statement defines an alternate name for the named type. Your named type is enum SIGNAL_VALUE. Your alternate name is?
JJaneba
September 24, 2018, 10:05am
3
"typedef" don't has influence to result (with and without) has the same bad result.
Known bug with a fix.
opened 01:27PM - 19 Sep 18 UTC
closed 03:16PM - 20 Sep 18 UTC
[This sketch](https://github.com/arduino/Arduino/files/2397217/ricette.txt) does… not compile on Arduino 1.8.7, producing the following error:
G:/Arduino/TAFFY/TAFFY_V1.3/TAFFY_V1.3.ino:65:19: error: 'ricetta' was not declared in this scope
This happens because the automatically generated function prototypes are inserted too early, before `struct ricetta` is defined, as shown in [the preprocessed sketch](https://github.com/arduino/Arduino/files/2397210/ricette.ino-187.txt).
This didn't happen in Arduino 1.8.5, which put the prototypes just before the setup() function. Preprocessor output is [here](https://github.com/arduino/Arduino/files/2397211/ricette.ino-185.txt).
This issue was raised by [user gianlucaf on the Arduino forums](http://forum.arduino.cc/index.php?topic=569238.0).
opened 01:40AM - 15 Sep 18 UTC
closed 09:49AM - 16 Oct 18 UTC
type: imperfection
topic: preprocessor
conclusion: resolved
topic: code
A.k.a. "Hello class, I found by the road some functions that look a bit like wha… t 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.
This will fix it:
https://github.com/arduino/arduino-builder/pull/294