Close

C++ on AVR32 with Atmel Studio 6 is a pain

A project log for Browser-Controlled Tracked Robot

A tracked vehicle for playing around with. Controlled from laptop for ubiqutousness, educational value and ... uh... data.

oldcrowOldCrow 10/17/2014 at 20:220 Comments

Dear diary. Remind me not to try "paths less trodden" quite so often.

I spent two evenings this week just trying to figure out why the binary size went from 3k to 50k. The only difference between before and after was my adding an instance of the freshly finished Servo4017 class to the SW.

Looking through the .map file I noticed that a lot of standard library functions, e.g. malloc, were getting linked in. Which I considered weird, since the only instance I'd added was definitely static. I started to remove anything that might cause it. I don't remember the exact order in which I bisected the class, but the problem disappeared immediately after I removed the destructor. Ah, ha...? And WTF...

So, lesson learned: don't be the first or the last to go somewhere. The first ones won't get paved roads, and the last ones usually don't come back with all their body parts.

TL;DR:

Adding a destructor to a C++ class in Atmel Studio causes it to link in half the standard library, including all possible memory control functions.

In other news, I soldered in the TSR-1 regulator for the servos and the 4017 IC itself. I didn't test the library yet though; I've been busy with real life and work. For the same reason you don't get a new photo. Well, I'm also not feeling like celebrating the addition of just a few more components. Let me reiterate: too much real life happening.

And don't get fooled by the front page picture getting changed. It's not a new photo; I just shuffled the photos around to get a better one as the preview image. I'm not usually much for PR, but getting one jolly wrencher and... uh... one follower?... after a few months of the project being up usually means one of two things: Either my project has absolutely no interest to anyone ever. Or I make a crappy first impression. Now, I'm not Einstein, Spielberg or Spock, but I'm rather certain that it's still the second option. And the only way to make a first impression in the project listings is the picture. So... advice for those who may follow: Put a front page photo that has actual object in it. Bonus points if it also has PCBs, gears (or other power transmission mechanics) and/or wiring. Extra bonus for shiny objects and blue LEDs. Trust me on this one.

Discussions