C++ Classes gets warning: alignment

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Whenever I use a C++ class I get the warning:
warning: alignment of `int (*Monitor::_ZTV7Monitor[3])(...)' is greater than maximum object file alignment. Using 1.

The code works fine - How can I lose this message?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you using the alignment attribute?

You'll have to show more of your code.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So far as I know I'm doing nothing at all out the ordinary! For what it's worth the code is:

class TaskDefinition
    {
  public:
    TaskDefinition*       m_NextTask ;
    char *                m_Description ;
    volatile unsigned int m_TaskTimer ;
    unsigned int          m_RepeatInterval ;
    unsigned int          m_Priority ;
    bool                  m_Debug ;

    virtual void          Execute(void) = 0 ;
    } ;
:
:
:
class Heart : public TaskDefinition
    {
  public:
    Heart() ;
    virtual void Execute(void) ;
    } ;

I'm new to AVR. The code works without any warnings on an H8! It also runs fine on the AVR - I just want the warning to go away.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm. That is odd.

You might have to post a bug report at the GCC project.

Realise that not too many people have been using C++ on the AVR (with GCC). So there might be issues that haven't been ironed out yet. :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

i have the same warning and its two years later now...
My Classes are really simple.

Do i have to switch something with a compiler option, to avoid this warning?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, the compiler has to be patched.

By now, you have to live with it. But the good news is
that it seems there's now really someone (Rolf Magnus) who's
interested in becoming the official C++ maintainer for the
AVR opensource toolchain.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thx, for your answer. I can live with that warning, because the program works fine ;)...

Using c++ classes instead of c funtions, needs more flash, but it's easier to use and to read. So i love c++ also on the avr and stay tuned...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also, Rolf Magnus has opened up a GCC bug report for this:
http://gcc.gnu.org/bugzilla/show...
And he also submitted a patch to GCC that will fix this problem. This patch will be working it's way through the various toolchain distributions soon.