Difficulties with IDE 1.6.x and several libraries

I have over 20 Arduino sketches that I have been developing on two computers for several years: one is a Win10 desktop and the other a Win7 Thinkpad notebook. I stayed with IDE 1.0.6 until a few months ago when I went to IDE 1.6.5 on the Desktop - it is still at 1.6.5 and it still compiles all my sketches OK. (all my sketches are duplicated on both computers)

A bit later I upgrades to IDE 1.6.6 on the Thinkpad and that was when i started having issues with libraries being out of date (notably Time, oneWire and DallasTemperature). I worked my way through that OK (somehow) but today i tried to take the Thinkpad up to 1.6.7 and the compile errors returned and I can’t work out the issue.

Using the library manager I updated the 5 libraries it suggested (DallasTemperature, DS1307RTC, FreqCount, OneWire, TimeAlarms). This didn’t work so I tried copying the sketches/libraries folder on my Desktop yto the Thinkpad but no change.

Attached is a ZIP of the whole code from just one of my affected sketches (Capmon1) and the errors messages. I emphasise that the problem is happening in many of my other sketches, mainly / often with errors like “‘XXX’ was not declared in this scope”, for example another sketch (Scoo4) reports similar errors with time_t plus errors associated with DeviceAddress array in the DallasTemperature library. One really weird thing is I can compile the related examples, which are what I would have based my code on originally …

Spent half a day already researching and experimenting, but no luck. Needless to say any suggestions greatly appreciated…

PS: should have mentioned I did do a completely fresh uninstall/reinstall to IDE 1.6.7 on the Thinkpad and downloaded and used fresh versions of PaulS libraries for Time, TimeAlarms and DS1307RTC

CAPmon1.zip (9.09 KB)

Compile errors Capmon1d IDE 167.pdf (47 KB)

Compile errors Scoo4v IDE 167.pdf (53.4 KB)

Are all those .ino files compiled together? That is, do they form one sketch? If so, you need to enable verbose mode during compilation (File + Preferences) and find the resulting .cpp file that is created from the ino files. There is something in that file that will provide a clue.

Do NOT wrap text in a PDF. It is much simpler and faster opening text files.

Paul, yes they form one sketch (each ino is just a tab in the IDE)

Attached the error report (as txt!) after compiling verbose. Not sure where I go from here, which cpp file, what am I looking for?

(As an aside I installed the IDE + libraries fresh on a virgin 3rd computer that runs Win10, and I get same errors)

Capmon1d verbose compile errors.txt (24.7 KB)

UPDATE: on a hunch I just combined all the separate tabs into one main tab only, and it compiled! I have double checked by re-combining another even larger sketch (~1900 lines) and now it compiles too.

BUT this is only partly good news. Sure it compiled, but for years I have been using multiple tabs to help me maintain structure and keep track of my fairly large sketches.

What could be causing this ... Why doesn't this happen using IDE 1.6.5 on my other computer? has something changed in the IDE?

thanks

ninja2:
Not sure where I go from here, which cpp file, what am I looking for?

When you compile a sketch with the Arduino IDE it automatically generates functions prototypes for any function that you haven’t done it manually for. To see the code after the Arduino IDE has had its way with it you need to look in the build folder. In the third line of the verbose output you posted:

C:\Program Files (x86)\Arduino 1.6.7\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino 1.6.7\hardware" -tools "C:\Program Files (x86)\Arduino 1.6.7\tools-builder" -tools "C:\Program Files (x86)\Arduino 1.6.7\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino 1.6.7\libraries" -libraries "C:\Users\cj\Documents\05 ARDUINO\Sketches\libraries" -fqbn=arduino:avr:uno -ide-version=10607 -build-path "C:\Users\cj\AppData\Local\Temp\buildc70ec08f55d72f48d4307eeedfac0d91.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\cj\Documents\05 ARDUINO\Sketches\CAPmon1\CAPmon1.ino"

You can see the build folder is “C:\Users\cj\AppData\Local\Temp\buildc70ec08f55d72f48d4307eeedfac0d91.tmp” if you open “C:\Users\cj\AppData\Local\Temp\buildc70ec08f55d72f48d4307eeedfac0d91.tmp”\sketch\CAPmon1.ino.cpp you can see what the IDE generated. The relevant portion is:

#include <Arduino.h>
#line 1
#line 1 "C:\\Users\\per\\Desktop\\CAPmon1\\CAPmon1.ino"
// Super Cap Tester - for USBDroid
#line 2 "C:\\Users\\per\\Desktop\\CAPmon1\\AA_SETUP.ino"
void setup();
#line 1 "C:\\Users\\per\\Desktop\\CAPmon1\\ALOOP.ino"
void loop();
#line 1 "C:\\Users\\per\\Desktop\\CAPmon1\\LCD.ino"
void displayTime(time_t t, int row, boolean show_date);
#line 40 "C:\\Users\\per\\Desktop\\CAPmon1\\LCD.ino"
void displayVoltsAmps(int row);
#line 49 "C:\\Users\\per\\Desktop\\CAPmon1\\LCD.ino"
void blankLCD(unsigned int row);
#line 1 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
time_t ComputeCorrectedTime(time_t t);
#line 16 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void RTC_load_NVRAM();
#line 23 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void ReportTime(time_t t, boolean textreport, boolean reportCorrected);
#line 52 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void ReportDuration(time_t duration);
#line 78 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void RTC_ResetTime();
#line 90 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void RTC_SetTime();
#line 98 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void RTC_AdjustDrift(int delta);
#line 109 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
float RTC_ReadFloat(int valAddr);
#line 124 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void RTC_WriteFloat(int valAddr, float value);
#line 138 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
long RTC_ReadLong(int valAddr);
#line 153 "C:\\Users\\per\\Desktop\\CAPmon1\\RTC.ino"
void RTC_WriteLong(int valAddr, long value);
#line 17 "C:\\Users\\per\\Desktop\\CAPmon1\\SD.ino"
void toggleLogging();
#line 34 "C:\\Users\\per\\Desktop\\CAPmon1\\SD.ino"
void addLogEntry();
#line 6 "C:\\Users\\per\\Desktop\\CAPmon1\\xaMISC.ino"
void printWithLeadingZero(int digits);
#line 10 "C:\\Users\\per\\Desktop\\CAPmon1\\xaMISC.ino"
void printFloat(double number, int digits, int decimals);
#line 37 "C:\\Users\\per\\Desktop\\CAPmon1\\xaMISC.ino"
void displayFloat(double number, int digits, int decimals);
#line 2
#define CJ_ID "CAPmon1.d"

#define CURRENT A6
#define VOLTAGE A7
#define RELAY   A2
//#define MEMORY_CHECK

//#define LCD4       4                        // Freetronics default
#define LCD4        A3                        // USBdroid only
#define LCD5         5                        // Freetronics default
#define LCD6         6                        // Freetronics default
#define LCD7         7                        // Freetronics default
#define LCDrs        8                        // Freetronics default
//#define LCDen      9                        // Freetronics default
#define LCDen       A1                        // USBdroid only

#include <SD.h>                               // microSD interface
#include <SPI.h>                              // required since IDE 1.5.4
#include <DS1307RTC.h>                        // DS1307 library: returns time as a time_t
#include <TimeLib.h>                          // new reference for Time.h (from IDE 1.6.5 or earlier)

Note that the function prototypes are declared before the TimeLib.h include.
Now if you combine all tabs into a single .ino file and compile and then look at the generated code the prototypes are after the includes. So why does this matter? Because in TimeLib.h is the line

typedef unsigned long time_t;

So if the function prototypes with time_t in them are declared before the TimeLib.h then time_t hasn’t been defined yet. Arduino IDE 1.6.6 changed the system of automatically generating prototypes to a new program called arduino-builder. This doesn’t seem to do as good a job at getting things right as the old system in many cases. So the way to be sure it will be done right is to just manually declare your function prototypes where they should be, then you can continue to use tabs.

Another option is to just use unsigned long instead of time_t, then you don't need to write the function prototypes.

pert:
So if the function prototypes with time_t in them are declared before the TimeLib.h then time_t hasn’t been defined yet. … So the way to be sure it will be done right is to just manually declare your function prototypes where they should be, then you can continue to use tabs.

many thanks pert for your great response and explanation

This is an aspect of programming I’m still learning … so, could I ask for a bit more explanation about what I actually have to do … I’m really keen to retain my tab structure, so is the code in each tab seen as a function prototype by the new builder? if so do I add a declaration somehow for each tab? or is it simply a matter of re-arranging my declarations somehow?

Alternately if I apply your other suggestion “just use unsigned long instead of time_t, then you don’t need to write the function prototypes.” - how would I do that ?

2nd last question (today :slight_smile: ) as I didn’t attach anything from my build folders, how did you get hold of the tmp extracts you included ?

Maybe it’s time I moved to an external editor - would that also resolve this issue?

ninja2:
could I ask for a bit more explanation about what I actually have to do … I’m really keen to retain my tab structure, so is the code in each tab seen as a function prototype by the new builder? if so do I add a declaration somehow for each tab? or is it simply a matter of re-arranging my declarations somehow?

Function prototypes just tell the compiler about the function so that if there is a call to it before the definition then the compiler already knows about it. For example the function prototype for your displayTime() would be:

void displayTime(time_t t, int row, boolean show_date)

So you just add that line anywhere after the line

#include <TimeLib.h>

and before any call to displayTime(). The only automatically generated function prototypes that are causing problems are the ones that have time_t return type or parameters so you don’t need to do all your functions if you don’t want to. So the full fix would be to add the following lines:

void displayTime(time_t t, int row, boolean show_date);
time_t ComputeCorrectedTime(time_t t);
void ReportTime(time_t t, boolean textreport, boolean reportCorrected);
void ReportDuration(time_t duration);

ninja2:
Alternately if I apply your other suggestion “just use unsigned long instead of time_t, then you don’t need to write the function prototypes.” - how would I do that ?

Edit > Find > Find: time_t, Replace with: unsigned long, Search all sketch tabs(check) > Replace All
Note that this could possibly not work for some situations where time_t is not an unsigned long but I see your sketch says it’s for USBDroid which is similar to an Uno so it should work fine for you.

ninja2:
2nd last question (today :slight_smile: ) as I didn’t attach anything from my build folders, how did you get hold of the tmp extracts you included ?

I have a back door on your computer. Just kidding! I just compiled your sketch on my computer with 1.6.7 and then opened the sketch in the build folder.

ninja2:
Maybe it’s time I moved to an external editor - would that also resolve this issue?

No I think it will be just the same, it’s arduino-builder causing the problem, not the editor, so your sketch will be run through arduino-builder either way.

Excellent thanks again … I added the prototypes to Capmon and it worked like a charm!

So I dived into my biggest sketch where I had to add a few more. Took me a couple of goes to realise prototypes aren’t always ‘void’ then my sketch compiled … yahoo.

After turning verbose off and reducing warnings to default and now I only get this warning:

WARNING: Category ‘’ in library OneWire is not valid. Setting to ‘Uncategorized’

Not sure if this is important of even if I can fix this, probably one for the library owner? (PaulS I think)

PS: please shut that back door as you leave :slight_smile:

Glad I was able to help!

ninja2:
Took me a couple of goes to realise prototypes aren't always 'void' , especially if time_t is involved. Not sure how to distinguish between void and non-void prototypes

The function prototype type should be the same as the function definition. For example, if you have the function:

byte foo() {
  return x+2;
}

Then the function prototype is:

byte foo();

In most cases it's just copy and paste and add a semicolon. Then you have to remember to update the prototype if you change the function. That's why I actually like the automatically generated prototypes feature of the IDE, it's tedious to do it manually. Unfortunately they made it much less reliable(though fixed a few rare problems) with arduino-builder. Well I guess the upside it it's taught a lot of people what function prototypes are, albeit in a not very fun way.

ninja2:
WARNING: Category '' in library OneWire is not valid. Setting to 'Uncategorized'

This warning can be ignored but you should be able to fix it by updating to version 2.3.2(assuming it's this one: GitHub - PaulStoffregen/OneWire: Library for Dallas/Maxim 1-Wire Chips you can use Library Manager to do the update.

ninja2:
probably one for the library owner? (PaulS I think)

Is PaulS and Paul Stoffregen the same person? I had thought that at one time but then noticed there are both users here. Well either way, they are both awesome!

now I reckon I'm actually proficient in function prototypes! tks

pert:
Is PaulS and Paul Stoffregen the same person? I had thought that at one time but then noticed there are both users here. Well either way, they are both awesome!

I had wondered too, recently I thought I got a clue they are. maybe 'PaulS' can confirm ? and while we're on this - what is PJRC in PJRC.com ? :slight_smile:

Totally agree on the awesomeness.

UPDATE: PJRC comes from Paul J Stoffregen and Robin C Coon. (owners of the PJRC site)

Paul J Stoffregen and I are two different people.

ahah, resolved ... double awesome :slight_smile: