Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Sketch compile error with VisualMicro, OK with Arduino IDE (Read 2403 times)
Akubi
Newbies
*
Offline


Posts: 2
Joined: Jan 2nd, 2017
Sketch compile error with VisualMicro, OK with Arduino IDE
Jan 2nd, 2017 at 11:22am
Print Post  
Hi,

I have a simple Sketch using MySensors library.
In order to override some définitions I need to declare a variable before the #include <MySensors.h> directive.

This work fine with Arduino IDE 1.6 and 1.8 but do not compile with VisualMicro integrated in Visual Studio 2015..

I attached the VisualMicro project.

Any idea ?

Thnak
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sketch compile error with VisualMicro, OK with Arduino IDE
Reply #1 - Jan 2nd, 2017 at 2:32pm
Print Post  
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:-

Code
Select All
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 Smiley

Code
Select All
//
// 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 ;
« Last Edit: Jan 2nd, 2017 at 2:33pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Akubi
Newbies
*
Offline


Posts: 2
Joined: Jan 2nd, 2017
Re: Sketch compile error with VisualMicro, OK with Arduino IDE
Reply #2 - Jan 2nd, 2017 at 6:06pm
Print Post  
Hi,

Thank for your answer. Ok that make sense  Wink

I will add prototypes for the moment. Hope you can improve that on a new release of your really great tool.

Thank again for the help.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint