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 Code Compiling in Arduino IDE but not VisualMicro (Read 4130 times)
Aerouta
Junior Member
**
Offline


Posts: 16
Location: USA
Joined: Feb 16th, 2013
Code Compiling in Arduino IDE but not VisualMicro
Jan 23rd, 2016 at 4:53pm
Print Post  
I have a question regarding compiling the code below. This code compiles perfectly using the Arduino IDE 1.6.x but fails when I attempt to use VM (lastest Versioin) and VS2015.

Code
Select All

/*********************************************************************
* INCLUDES
*/
#include <string.h>
#include <Wire.h>
/*********************************************************************

*/

/*********************************************************************
* MACROS
*/
#define CLEAR_BUFFER(BUF)              memset(BUF, 0, sizeof(BUF))
#define SEND_REQUEST(REQUEST)          Serial1.print(REQUEST)
#define READ_RESPONSE(RESPONSE)        Serial1.readBytes(RESPONSE, _RX_MAX_LEN)
#define COPY_SRC_TO_DEST(SRC,DEST,LEN) memset(DEST, 0, sizeof(DEST)); \
                                       memcpy(DEST,SRC,LEN); \
                                       LEN = 0

#define COPY_LINE_SRC_TO_DEST(SRC,DEST) do{ \
                                          memset(DEST, 0, sizeof(DEST)); \
                                          for(int i =0;i<strlen(SRC);i++) \
                                          { \
                                              DEST[i] = SRC[i]; \
                                              if(DEST[i-1]=='\r' && DEST[i]=='\n') \
                                              { \
                                                  DEST[i-1]= 0; \
                                                  DEST[i]= 0; \
                                                  break; \
                                              } \
                                          } \
                                        } \
void setup()
{
	Serial.begin(115200);
	Serial.println("Start");
}

void loop()
{
  /* add main program code here */
}

 

  

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


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Code Compiling in Arduino IDE but not VisualMicro
Reply #1 - Jan 23rd, 2016 at 5:09pm
Print Post  
Thanks for the info.

Can you please recheck your textual code example. It fails in both arduino 1.6.7 and Visual Studio intellisense also reports the same error with missing }

I know this is a different error than you have reported so I will retest after you check the example.

Thanks very much
  
Back to top
IP Logged
 
Aerouta
Junior Member
**
Offline


Posts: 16
Location: USA
Joined: Feb 16th, 2013
Re: Code Compiling in Arduino IDE but not VisualMicro
Reply #2 - Jan 23rd, 2016 at 5:32pm
Print Post  
needed a blank line before void setup.  This code should work

Code
Select All

#include <string.h>
#include <Wire.h>

/*********************************************************************
* MACROS
*/
#define CLEAR_BUFFER(BUF)              memset(BUF, 0, sizeof(BUF))
#define SEND_REQUEST(REQUEST)          Serial1.print(REQUEST)
#define READ_RESPONSE(RESPONSE)        Serial1.readBytes(RESPONSE, _RX_MAX_LEN)
#define COPY_SRC_TO_DEST(SRC,DEST,LEN) memset(DEST, 0, sizeof(DEST)); \
                                       memcpy(DEST,SRC,LEN); \
                                       LEN = 0

#define COPY_LINE_SRC_TO_DEST(SRC,DEST) do{ \
                                          memset(DEST, 0, sizeof(DEST)); \
                                          for(int i =0;i<strlen(SRC);i++) \
                                          { \
                                              DEST[i] = SRC[i]; \
                                              if(DEST[i-1]=='\r' && DEST[i]=='\n') \
                                              { \
                                                  DEST[i-1]= 0; \
                                                  DEST[i]= 0; \
                                                  break; \
                                              } \
                                          } \
                                        } \

void setup()
{
  Serial.begin(115200);
  Serial.println("Start");
}

void loop()
{
  /* add main program code here */
}
 

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Code Compiling in Arduino IDE but not VisualMicro
Reply #3 - Jan 23rd, 2016 at 5:46pm
Print Post  
I tried the code below and it works with each define on the same line.

There is some sort of brace collapse / prototype resolution clash during .ino pre-process. 

I guess a short term fix is to place the #defines in a .h and #include in the .ino or place on one line like the following example.

Thanks for reporting.

Code
Select All
/*********************************************************************
* INCLUDES
*/
#include <string.h>
#include <Wire.h>
/*********************************************************************

*/

/*********************************************************************
* MACROS
*/
#define CLEAR_BUFFER(BUF)              memset(BUF, 0, sizeof(BUF))
#define SEND_REQUEST(REQUEST)          Serial1.print(REQUEST)
#define READ_RESPONSE(RESPONSE)        Serial1.readBytes(RESPONSE, _RX_MAX_LEN)
#define COPY_SRC_TO_DEST(SRC,DEST,LEN) memset(DEST, 0, sizeof(DEST)); memcpy(DEST,SRC,LEN); LEN = 0
#define COPY_LINE_SRC_TO_DEST(SRC,DEST) do{memset(DEST, 0, sizeof(DEST)); for(int i =0;i<strlen(SRC);i++) { DEST[i] = SRC[i]; if(DEST[i-1]=='\r' && DEST[i]=='\n') { DEST[i-1]= 0; DEST[i]= 0;  break; } } } 

void setup()
{
	Serial.begin(115200);
	Serial.println("Start");
}

void loop()
{
	/* add main program code here */
}
 



« Last Edit: Jan 24th, 2016 at 4:37pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Aerouta
Junior Member
**
Offline


Posts: 16
Location: USA
Joined: Feb 16th, 2013
Re: Code Compiling in Arduino IDE but not VisualMicro
Reply #4 - Jan 23rd, 2016 at 9:39pm
Print Post  
thanks for the tip.

The "\" must be removed for the define statements to be used, otherwise it errors once the defines are called.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Code Compiling in Arduino IDE but not VisualMicro
Reply #5 - Jan 24th, 2016 at 4:38pm
Print Post  
Thanks shows how much I know Smiley I have edited the post for clarity
« Last Edit: Jan 24th, 2016 at 4:38pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint