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 This program compiled and worked before I upgraded Arduino Ide ? (Read 7949 times)
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
This program compiled and worked before I upgraded Arduino Ide ?
Aug 15th, 2015 at 12:30pm
Print Post  
On a new computer running Win 10 I have installed Atmel Studio and Visual Micro and copied over all my old projects.
One of which have compiled fin before. But now I get these compiler errors

Compiling 'TestPrecRTCClock' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
DateStrings.cpp:41:22: error: variable 'monthNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DateStrings.cpp:58:20: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DateStrings.cpp:59:24: error: variable 'dayShortNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DefaultFonts.c:21:14: error: variable 'SmallFont' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DefaultFonts.c:125:14: error: variable 'BigFont' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DefaultFonts.c:234:14: error: variable 'SevenSegNumFont' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
SevenSegmentFull.c:8:9: error: variable 'SevenSegmentFull' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Error compiling

And the program is listed below

Code (C++)
Select All
//140708 Fungerar (works fine)
#include <UTFT.h>
#include <memorysaver.h>
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>

#include <memorysaver.h>

extern			uint8_t BigFont[];
extern			uint8_t SevenSegmentFull[];

UTFT	myGLCD(ITDB32S,38,39,40,41);

const char *monthName[12] =
{
	"Jan", "Feb", "Mar", "Apr", "May", "Jun",
	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

tmElements_t	tm;								//Declare tmElements object to store time & date from DS3231

void setup()
{
  bool parse=false;
  bool config=false;
  /* add setup code here */
  Serial.begin(9600);
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();
  myGLCD.fillScr(255,255,255);
  myGLCD.setBackColor(255, 255, 255);
  myGLCD.setColor(0, 0, 255);
  Serial.println("Testing precision clock");
  Serial.println("Date and Time");
  // get the date and time the compiler was run
  if (getDate(__DATE__) && getTime(__TIME__))
  {
	  parse = true;
	  // and configure the RTC with this info
	  if (RTC.write(tm))
	  {
		  config = true;
	  }
  }

  while (!Serial) ; // wait for Arduino Serial Monitor
  delay(200);
  if (parse && config)
	{
	  Serial.print("DS1307 configured Time=");
	  Serial.print(__TIME__);
	  Serial.print(", Date=");
	  Serial.println(__DATE__);
	}
  else if (parse)
	{
	  Serial.println("DS1307 Communication Error :-{");
	  Serial.println("Please check your circuitry");
	}
  else
	{
	  Serial.print("Could not parse info from the compiler, Time=\"");
	  Serial.print(__TIME__);
	  Serial.print("\", Date=\"");
	  Serial.print(__DATE__);
	  Serial.println("\"");
	}
	myGLCD.setFont(BigFont);
	myGLCD.print("Klockan",CENTER,1);
	myGLCD.setFont(SevenSegmentFull);
}

void loop()
{
  /* add main program code here */
  if(RTC.read(tm))  //Read the time & date from DS3231, if success, print time & date on LCD
	{	  	 
	  myGLCD.printNumI(tm.Hour/10   ,32,19);
	  myGLCD.printNumI(tm.Hour%10   ,64,19);
	  myGLCD.print(":",96,19);
	  myGLCD.printNumI(tm.Minute/10,128,19);
	  myGLCD.printNumI(tm.Minute%10,160,19);
	  myGLCD.print(":",192,19);
	  myGLCD.printNumI(tm.Second/10,224,19);
	  myGLCD.printNumI(tm.Second%10,256,19);
	  myGLCD.print(monthName[tm.Month-1],1,68);
	}
  else if (RTC.chipPresent())
	  Serial.println("Chip present\n\r");
  else
      Serial.println("Error");
 
  myGLCD.setFont(SevenSegmentFull);
}

bool getTime(const char *str)
{
	int Hour, Min, Sec;

	if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
	tm.Hour = Hour;
	tm.Minute = Min;
	tm.Second = Sec;
	return true;
}

bool getDate(const char *str)
{
	char Month[12];
	int Day, Year;
	uint8_t monthIndex;

	if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
	for (monthIndex = 0; monthIndex < 12; monthIndex++) {
		if (strcmp(Month, monthName[monthIndex]) == 0) break;
	}
	if (monthIndex >= 12) return false;
	tm.Day = Day;
	tm.Month = monthIndex + 1;
	tm.Year = CalendarYrToTm(Year);
	Serial.print("Year=");
	Serial.println(tm.Year);

	return true;
}


 

« Last Edit: Aug 15th, 2015 at 4:29pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: This program compiled and worked before but not now ?
Reply #1 - Aug 15th, 2015 at 12:34pm
Print Post  
Hi Jan,

I think you have upgraded your arduino ide which uses new tool chains.

The new tool chains requires read-only variables to be declared "const"

You should see the same error if you compile with the Arduino Ide.
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: This program compiled and worked before but not now ?
Reply #2 - Aug 15th, 2015 at 3:05pm
Print Post  
Tim@Visual Micro wrote on Aug 15th, 2015 at 12:34pm:
Hi Jan,

I think you have upgraded your arduino ide which uses new tool chains.

The new tool chains requires read-only variables to be declared "const"

You should see the same error if you compile with the Arduino Ide.


Yes I use the latest 1.6 IDE. Does this mean that I will have to manually edit the library files I use ? In this case the errors are in a library file DateStrings.cpp .
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: This program compiled and worked before I upgraded Arduino Ide ?
Reply #3 - Aug 15th, 2015 at 4:23pm
Print Post  
Yes that's right.

You can click "Project>Show Arduino Core and Library Sources" for quick access to edit via the code editor.
« Last Edit: Aug 15th, 2015 at 4:29pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: This program compiled and worked before I upgraded Arduino Ide ?
Reply #4 - Aug 16th, 2015 at 3:38pm
Print Post  
Tim@Visual Micro wrote on Aug 15th, 2015 at 4:23pm:
Yes that's right.

You can click "Project>Show Arduino Core and Library Sources" for quick access to edit via the code editor.


It wasn't that simple. I added const to all the lines I had compiler errors for. After that I got
and I see this in DateStrings.cpp
Code (C++)
Select All
#define PGM_P  const char *
 


so I don't understand why there was a compiler error in the first place

Compiling 'TestPrecRTCClock' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
DateStrings.cpp:41:7: error: duplicate 'const'
DateStrings.cpp:41:28: error: variable 'monthNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DateStrings.cpp:58:7: error: duplicate 'const'
DateStrings.cpp:58:26: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Error compiling

« Last Edit: Aug 16th, 2015 at 3:41pm by Jan Friberg »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: This program compiled and worked before I upgraded Arduino Ide ?
Reply #5 - Aug 16th, 2015 at 5:28pm
Print Post  
Ok, I think the arduino.cc forum is best place for that. I'm not an expert with the arduino cores.
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: This program compiled and worked before I upgraded Arduino Ide ?
Reply #6 - Aug 17th, 2015 at 11:58am
Print Post  
Tim@Visual Micro wrote on Aug 16th, 2015 at 5:28pm:
Ok, I think the arduino.cc forum is best place for that. I'm not an expert with the arduino cores.


Maybe I should list the previous code line in context

Code (C++)
Select All
#if defined(__AVR__)
#include <avr/pgmspace.h>
#else
// for compatiblity with Arduino Due and Teensy 3.0 and maybe others?
#define PROGMEM
#define PGM_P  const char *
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned char **)(addr))
#define strcpy_P(dest, src) strcpy((dest), (src))
#endif
#include <string.h> // for strcpy_P or strcpy
#include "Time.h"
 


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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: This program compiled and worked before I upgraded Arduino Ide ?
Reply #7 - Aug 17th, 2015 at 12:07pm
Print Post  
Well you can obviously read because you have quoted my text  Smiley
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint