Vs2015+Visual Micro + MySensors
-
Hi,
I've tried to migrate from the arduino IDE to the VS2015 Community+Visual Micro support for Arduino.
When attempting to compile a sketch with MyMessage and receive handler I get an error "BatteryPoweredWaterLeakSensor.ino:39:20: error: 'MyMessage' does not name a type"When excluding the define of MyMessage and the receive handler there is no problem and project compile with no errors:
void receive(const MyMessage &message) { }Compiling the same sketch with the Arduino IDE or when removing the MyMessage usage I get no errors.
Any idea?
-
OK,
I was able to find the RCA.
Apparently, the issue was related to the location of the #include and the const variables.
The following code generates errorconst int SENSOR_ANALOG_PINS[] = { A0, A1 }; #include <SPI.h> #include <MySensors.h> #define CHILD_ID_SENSOR 0 #define CHILD_ID_VOLTAGE 1 MyMessage msgTripped(CHILD_ID_SENSOR, V_TRIPPED); MyMessage msgVoltage(CHILD_ID_VOLTAGE, V_VOLTAGE);The following code is GOOD. Hence, the const values has to be defined post the header include
#include <SPI.h> #include <MySensors.h> #define CHILD_ID_SENSOR 0 #define CHILD_ID_VOLTAGE 1 MyMessage msgTripped(CHILD_ID_SENSOR, V_TRIPPED); MyMessage msgVoltage(CHILD_ID_VOLTAGE, V_VOLTAGE); const int SENSOR_ANALOG_PINS[] = { A0, A1 }; -
I can absolutely confirm this with VS2015, Visual Micro and MySensors 2.1.1. This is clearly a kind of merging, that is done by Visual Micro.
All includes have to be made BEFORE the first line of code is executed. The initialization of your
SENSOR_ANALOG_PINSarray is such a line of code.Just posting it to keep it visible and well-scored at search engines, as this is SOLVED and works fine. Thank you!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login