svn tip: branch stable version, then use externals

Even though the title says svn, this tip is applicable probably for any version control system. Imagine the following scenario: You have project BestAppEver. BestAppEver depends on BestLibEver. Both are using svn. How do you handle this on your version control system?

One way, the wrong way, that I have seen lots of times is to just include a copy of BestLibEver inside BestAppEver, like this:

This is horrible, whenever BestLibEver is updated you need to manually update BestAppEver. Thus, we come to the second (but not quite the best) solution: svn externals. They work like this:

Again, although I said svn externals, most version control systems have their own externals version. For a detailed explanation on how externals work you should read the link above, for the moment let’s just say this is enough to setup the external:

$ svn pe svn:externals .
# This will open your default editor. Now write this:
LibName           LibURL

Now every time you run an svn update, it will fetch the latest version of BestLibEver. We have a problem though: BestLibEver may be a project with a lot of commits, and the head revision may be very unstable. Not only it may crash (being a development version, it wouldn’t be a strange thing) but also its interfaces may be constantly changing. And we certainly don’t want to spend all day just changing our wrappers to make the project compile again.

There is a solution for this, and we don’t have to go back to the first method of just copying the trunk to our repository: we can ask the maintainer of BestLibEver to just create a branch (or a tag, for this case it’s pretty much the same) for a stable version and then use an external to that branch. Like this:

Now the team developing BestLibEver can work without complaints from their users and BestAppEver can have a stable svn, with controlled lib upgrades whenever they want.


Fixing some annoying GTK Warnings

So, new Buguntu upgrade, new problems. The usual deal. I don’t like Unity so I installed the usual gnome desktop. Now when I start gVim I get a bunch of errors like this:

(gvim:7189): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap"

OK, not errors, just warnings. I don’t like them anyway, so I did this to fix it:

sudo apt-get install gtk2-engines-pixbuf

Now it works. One problem less, NaN to go… time to move back to Debian?

C++ name mangling

There is a topic I have referred to several times on this blog, yet in four years I still haven’t explained what it is. I plan to correct this by explaining a little bit about C++ name mangling, and although I won’t expect to write anything you couldn’t learn by reading Wikipedia, I’ll try to have a more practical approach.

Whenever you compile and link something, there is a lot of information the compiler deduces that you don’t really care about. Things like calling conventions, overloads or namespaces. Yet this information is crucial for other stages of the compiler (or linker) to work. For this reason, the compiler will create a decorated version of any object’s or function’s name.

In its most simple case, it would be something like this:

void overloaded_function(int);
void overloaded_function(string);

Which would then be translated to something like:

void fastcall_int_overloaded_function(int);
void fastcall_string_overloaded_function(string);

Of course, for more complex functions (like class methods) the mangling is much more complicated. Also, remember that’s just a mangling convention I just invented, and most likely not used by any compiler in existence.

Although for the most part we can just ignore name mangling, this has a couple of consequences of which we should be aware:

Creating a name for anonymous objects/functions

I will not explain much about this, it might be the topic of another post, but there are certain cases in which you can have a struct or a function defined inside another object anonymously. In these cases, the mangler will assign some sort of denomination for this anonymous object.

Linking with C symbols

C has no mangling. It just doesn’t need it. This has a very important consequence, whenever you use C code in C++ you need to specify that your doing so, by using an extern “C” declaration.


gdb already takes care of this so it may be transparent to you, but if you are using a debugger not aware of how your compiler mangles names, you may end up with a lot of very difficult to understand names.

Bonus: Demangling C++ names

If you find yourself in the last case, for example when running an nm to get the names defined in a (compiled) object, you can use c++ filt. Like this:

nm foo.o | c++filt

New Buguntu, new GUI, new problems

I updated Ubuntu to 11.10 in one of three computers I regularely use. Lot’s of problems and very little improvements. Granted, sound now works by default (finally) but dual screen suport is still less than what I would expect from Windows 98. On top of that, the biggest change is the GUi.

WTF! My computer is not a tablet, give me back my menu. While using my phone it’s nice to have only a couple of icons to click. With two big monitors, I miss my launch bar, a propper clock, my custom applets and the applications menu… everything that makes the GUI usable.

Luckly Ubuntu provides a way to revert to the “classic” desktop, you just need to apt-get install gnome-session-fallback (WTF? I need to INSTALL it? If you plan to roll out a new experimental GUI, at least let me opt-out without downloading more stuff). Of course, since now Ubuntu comes with Gnome 3 even more fun ensues.

Did you plan to customize your toolbars? Well, good luck with that. Apparently now the applets that work for the old Gnome won’t work for Gnome 3. Yes, they implemented a new cool applet system, whatever, I just want a port of the old ones I had.

Oh, if you plan to move things around you’ll have to do some research first. See that hideous clock up there, in the top bar? How would you get it to the lower-right corner? Why, hold alt and then right click to see the move menu. Super intuitive. I wonder if they inspired themselves on ribbon.

I don’t understand the tablet-interface-ftw fad, I was happy with my console multiplexer and I want to keep it unobtrusive, as gnome 2 was. Time to switch to XFCE?