Pages: [1]   Go Down
Author Topic: TM1640 demo sketch works for ATtiny85 in IDE0022, but not newer versions  (Read 411 times)
0 Members and 1 Guest are viewing this topic.
Brisbane, Australia
Online Online
Edison Member
*
Karma: 29
Posts: 1071
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I've been trying to use the TM1638 library (from https://code.google.com/p/tm1638-library/) with the ATtiny85, inspired by this instructible.  I'm using the arduino-tiny cores, not the MIT ones in that instructible.  What I'm finding is with any of the younger IDE versions I'm getting this error when I try to verify:
Code:
TM1638\TM16XX.cpp.o:(.rodata._ZTV6TM16XX+0x14): undefined reference to `__cxa_pure_virtual'
I've tried 1.0, 1.0.1 and 1.0.4; I've also tried the TM1638 libraries v2.0.1 (the version used in that instructible it appears) and the latest 2.1.3 but in all combinations of those that error occurs.

If I roll back to Arduino IDE 0022 it compiles though.  And that's with either library version.
Code:
Binary sketch size: 4042 bytes (of a 8192 byte maximum)

I'm using the code from the instructible, but the standard 2.1.3 example for TM1640 compiles okay also.

As a fallback I'll be completing this project in Arduino IDE0022, but it would be nice not to have to go retro.  Any ideas what this error is pointing to?

Thanks,
Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I means that somewhere in the program a pure virtual function is declared then an object is created without supplying a definition for that function.

If you can find a function in the library that looks like this:

virtual void someFunction(...)=0;

Change it to this:

virtual void someFunction(...) { }

That should get it to compile...whether or not it works correctly is another matter. Technically it s bug in the program.

Logged

No, I don't answer questions sent in private messages...

Brisbane, Australia
Online Online
Edison Member
*
Karma: 29
Posts: 1071
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi fungus

The nearest thing I've found (and the only reference to the word virtual) doesn't use the virtual keyword
Code:
#if !defined(ARDUINO) || ARDUINO < 100
// empty implementation instead of pure virtual for older Arduino IDE
void TM16XX::sendChar(byte pos, byte data, boolean dot) {}
#endif
In the header there's this
Code:
  protected:
#if defined(ARDUINO) && ARDUINO >= 100
// pure virtual is NOT supported in older Arduino IDE
virtual void sendChar(byte pos, byte data, boolean dot) = 0;
#else
virtual void sendChar(byte pos, byte data, boolean dot);
#endif
From what you're saying above, should there be a corresponding #else definition in the cpp file for IDE versions 100+ that's missing?

Thanks
Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4549
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Technically speaking, there's a bug in the program. You've declared a function:

Code:
virtual void sendChar(byte pos, byte data, boolean dot) = 0;

But you didn't provided a definition for it in a derived class.

If you can find a function called "sendChar(...)" in a derived class which has a slightly different declaration (eg. it might have a 'char' instead of a 'byte' or something in the function parameters) then that's the bug. Modify it to match the function in the header, it will override the empty function and Bob's your auntie's life-partner.


If you can't find anything like that, the best bet is to remove the pure virtual declaration. This give you pre-1.00 behavior everywhere.

ie. In the header do this:
Code:
protected:
virtual void sendChar(byte pos, byte data, boolean dot);

In the other file do this:
Code:
// empty implementation for *ALL* IDEs
void TM16XX::sendChar(byte pos, byte data, boolean dot) {}

« Last Edit: April 22, 2013, 07:35:36 am by fungus » Logged

No, I don't answer questions sent in private messages...

Brisbane, Australia
Online Online
Edison Member
*
Karma: 29
Posts: 1071
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Fungus you are a champion.  It compiles in 1.01 etc now without an error.   I've also submitted this as an issue to the library author with a link here to your explanation.

Thanks ! Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Pages: [1]   Go Up
Jump to: