Thanks for posting part of the code. Without the full code it would help if you posted the error message.
I am going to guess and say this is due to some new functionality in the arduino ide last year which isn't in visual micro yet. It's the last outstanding job and is more complicated for visual micro because of debug etc.
Arduino and visual micro have to create and insert prototypes into the code prior to compile in a hidden folder. Currently visual micro inserts the prototypes before the first line of code.
In your code the first line is prior to the #include sensors.h which is:-
uint8_t RF24_Channel = MY_DEFAULT_RF_CHANNEL;
and I guess that sensors.h defines the MyMessage type so inserting a prototype between the above code and sensors.h would cause a compile issue. As you rightly suggest.
You can avoid the issue by creating your own prototype. Both arduino and visual micro will be happy with this.
Notice below your code has been altered to #include a prototype for the method that has a signature containing your custom type. Actually you can always add prototypes yourself in the same way you do for c++/.cpp files.
nb: An alternative would be to move RF24_Channel so that is after the sensors.h but that might be what you wanted to avoid
//
// Test1.ino
//
#define MY_RADIO_NRF24 // Enable and select radio type attached
#define MY_DEFAULT_RF_CHANNEL 76 // Default RF Channel at first initialisation
#define MY_RF_EEPROM 250 // EEPROM Slot of the RF Channel
uint8_t RF24_Channel = MY_DEFAULT_RF_CHANNEL;
#define MY_RF24_CHANNEL RF24_Channel
#include <MySensors.h>
// prototypes
//
void receive(const MyMessage &message);
//
//
#define NODE_PRESENTATION_NAME "Test1"
#define NODE_PRESENTATION_VERSION "0.1"
#define RELAY_CHILD_ID 1 // Id of the sensor child
#define RELAY_CHILD_NAME "Test" // Default name of the sensor child
#define RELAY_CHILD_TYPE S_LIGHT // Type of command
#define RELAY_CHILD_VALUE_TYPE V_LIGHT // Type of value data
#define RELAY_CHILD_EEPROM 1 // EEPROM Slot of the sensor child
void before() {
// Change Radio Channel
if (loadState(MY_RF_EEPROM) == 0xFF)
{
saveState(MY_RF_EEPROM, MY_DEFAULT_RF_CHANNEL);
}
RF24_Channel = loadState(MY_RF_EEPROM);
}
void presentation() {
sendSketchInfo(NODE_PRESENTATION_NAME, NODE_PRESENTATION_VERSION); // Send the Node Name and Version information to the gateway and Controller
present(RELAY_CHILD_ID, RELAY_CHILD_TYPE, RELAY_CHILD_NAME); // Register all Childs to the Gateway and controller
}
void receive(const MyMessage &message) {
}
void receiveTime(unsigned long time) {
}
void loop() {
}
Prototypes must have the exact same signature as the method and end with a semi-colon ;