Monthly Archives: December 2007

C conundrum (below)

I've got a problem with C.

I'm trying to do something like the following:

#define FOOBAR 5
some_function_which_takes_an_integer (FOOBAR);
...
some_function_which_takes_a_string ("String literal with FOOBAR concatenated: "FOOBAR);

Which I want to expand to:

some_function_which_takes_an_integer (5);
...
some_function_which_takes_a_string ("String literal with FOOBAR concatenated: 5");

Unfortunately, I can't, and I can't see a way to do it. I'm basically looking for a way to stringise a preprocessor token's value so that it can be concatenated with other string literals before the compiler is allowed to molest it.

I've been talking with a friend, and seeing as there's a # preprocessor operator which stringises token names, it would make sense that there would be one for token values, but he can't think of one, or any other way to do it apart from using sprintf.

One other way of doing it would be to have two different versions of each preprocessor token – one an integer, and one a string – but that's ugly.

Anybody got any ideas?
Continue reading

Totem docs, go-karting and BIO

It's been a busy week, but things should now be winding down (or up) for Christmas.

To begin with, I've got an e-mail from Kirk Bridger sitting in my inbox with a usability review of Totem's Tracker plugin. I'm trying to find some time to go through it and deal with the five issues he brings up, since they're all problems on one level or another. I've just about missed the period before UI change announcement comes in, but I should be able to get it done before the UI freeze.

Another area Totem's getting some work done in is documentation. We've got two bugs open at the moment about it, and some other changes lying around in my local checkout. The current documentation for Totem ostensibly relates to version 1.6, but I suspect it's actually a mish-mash of documentation for several versions, with small areas changed as and when necessary. It might be an idea to set another GHOP task to update the documentation.

Away from GNOME, I went go-karting yesterday as an outing to celebrate my brother's birthday. Although it was freezing, we had fun, and my dad, brother and I all came very close together; if it wasn't for each others' mistakes, we wouldn't have got past anyone at all. The problem now is that I ache everywhere, due to the kart's seat being slightly too big, and the fuel tank being just a bit too wide to sit comfortably between my legs.

Moving back towards computing, I sat the British Informatics Olympiad again on Friday. I found it a lot easier this year than I previously have, as this year, VC++6 was available on the computers at school for me to use. In previous years I've been forced to use Visual Basic 6, and the lack of decent arrays makes taking the olympiad like swimming in treacle with your hands tied behind your back look easy.

Thanks to being able to use C, I managed to get complete solutions to the first two questions, and was half-way through a solution to the third (although I'm not sure I was taking the right approach) when the time ran out. Hopefully I'll have got more than half marks this year. :)