Pages: [1]   Go Down
Author Topic: moving library from 0017 to 1.0  (Read 631 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I am running on a PC using (mainly) ATMega644P micros.  An application running well under Arduino 17 is failing to compile under 1.0.

  I can replicate the problem with one private library and a tiny test program.  In its entirety, the library's header is
Code:
/* DS1307 library, from old include file */
#include "Arduino.h"

#define DS1307_SecondsReg    0            // followed by min, hrs, DOW (1-based!), Day, Mo, Yr
#define DS1307_YearReg       6       
#define DS1307_1st           DS1307_SecondsReg
#define DS1307_Last          DS1307_YearReg
#define DS1307_NBytes        DS1307_Last - DS1307_1st + 1

#ifndef DS1307_h
  #define DS1307_h
 
  class tDateTime
    {  private:
         void AssembleOneElement(char* S, int Index, int Value);
        public:
         tDateTime();
         unsigned long Year;
         unsigned long Month;
         unsigned long Day;
         unsigned long Hour;
         unsigned long Minute;
         unsigned long Second;
                                 //           11
                                 // 012345678901
         char TimeAsString[13];  // YYMMDDHHmmSS";
         void Assemble(void);
         void AssembleIntoString(char* S);
         int  DaysInMonth(int M, int Y);
         void Disassemble(void);
         void DisassembleFromString(char* S);
         void Normalize(void);
         unsigned long SecondsSince1999();
    }; // tDateTime
 
  class DS1307
    { private:
        int  BCDToInt(byte B);
        void FillAsciiBigTime(int Index, int Value);
        byte IntToBCD(int N);
        byte ReadBuffer[DS1307_NBytes];
        void SetControlRegister();
      public:
        DS1307();
        tDateTime TheDateTime;
        int WeekdayM0;   // Day of week, Monday = 0, Tuesday = 1, ..., Sunday = 6
                               //           11
                               // 012345678901
        char AsciiBigTime[13]; // YYMMDDHHmmSS";
        void ReadTime(void);
        void SetAsciiBigTime(unsigned long AddedSeconds);  // changes only printable form
        void SetTime();                                    // changes registers
        void setup_1307();
    }; // DS1307
   
#endif


with
Code:
DS1307::DS1307()
  { TheDateTime = tDateTime();
  } // create object
appropriately in DS1307.cpp.  The test program has a few declarations before
Code:
#include "G:\hardware\freestanding\Arduino 1.0\libraries\DS1307\DS1307.h"
DS1307 TheDS1307 = DS1307();

but that's enough to get the compilation to fail.  In response to the second quoted line, the compiler complains
Code:
Test_DS1307.cpp.o: In function '_static_initialization_and_destruction_0':

C:\Users\RobertT~1.FEN\AppData\Local\Temp\build6736133756654905411.tmp/Test_DS1307.cpp:12: undefined reference to 'DS1307::DS1307()'

  My guess is that the problem is somehow related to a change in the Arduino IDE's perverse notions about how directories must be structured, but various experiments moving the library from one directory to another haven't helped.  I am aware that the Arduino software frequently fails to clean up after itself, but deleting the object files (and, indeed, the whole applet directory) doesn't help either.

  Any help will be appreciated.
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not replace
Code:
DS1307 TheDS1307 = DS1307();

with:
Code:
DS1307 TheDS1307 ();

while you're at it?
Logged

[ I won't respond to messages, use the forum please ]

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Insert Quote
Why not replace
Code:

DS1307 TheDS1307 = DS1307();


with:
Code:

DS1307 TheDS1307 ();


while you're at it?

  My C++ programming style is borrowed from Delphi, in which I've done most of my programming for the last 20 years or so.  In Delphi, declaration and instantiation of objects are generally separated.  Here, the suggested stylistic change doesn't change the compilability of my test code.
Logged

Pages: [1]   Go Up
Jump to: