Archive

Archive for the ‘development’ Category

Better Threads with Active Objects

July 14th, 2010 niels No comments

As part of his Effective Concurrency column, Herb Sutter describes the Active Object Pattern this month.
It’s not just a C++ thing, but usable in C# and Java as well.

Suggested reading :)

Tags:

Displaying the latest global Subversion revision ID in an application

June 21st, 2010 niels No comments

When you have to display the latest global svn revision number in your application you face different options.
Using Subversion keywords, like $Revision$ or $Id$, sounds like the most natural approach. Unfortunately the keywords are updated only when you change and commit the corresponding file. In short: if you intend to grab the revision ID from a central header file, like version.h, this file has to be edited and committed whenever a svn commit on any file in your project takes place. So either you do that manually (“erm, no?” – right!), or you create a commit hook and bloat your repository.
Another approach is to fetch the latest number of the latest revision and update your version.h as part of your build. In short: whenever you trigger a build by calling make, ant or build your project in your IDE, you invoke a script that generates your header file (or .java, .cs, .rb … you name it). On Linux and Unix, you might use a script just like this:
Read more…

Fighting Windows Sockets Legacy Troubles

May 14th, 2010 niels No comments

I came across a really annoying problem while using win32 sockets one of my bigger projects. In short, the VisualC compiler complained about redefinitions of basic Windows socket macros:

C:\sdk\windows\v6.0a\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
C:\sdk\windows\v6.0a\include\winsock.h(460) : see previous definition of 'AF_IPX'
C:\sdk\windows\v6.0a\include\ws2def.h(124) : warning C4005: 'AF_MAX' : macro redefinition
C:\sdk\windows\v6.0a\include\winsock.h(479) : see previous definition of 'AF_MAX'
C:\sdk\windows\v6.0a\include\ws2def.h(163) : warning C4005: 'SO_DONTLINGER' : macro redefinition
C:\sdk\windows\v6.0a\include\winsock.h(402) : see previous definition of 'SO_DONTLINGER'
C:\sdk\windows\v6.0a\include\ws2def.h(206) : error C2011: 'sockaddr' : 'struct' type redefinition
C:\sdk\windows\v6.0a\include\winsock.h(485) : see declaration of 'sockaddr'
C:\sdk\windows\v6.0a\include\ws2def.h(384) : error C2143: syntax error : missing '}' before 'constant'
C:\sdk\windows\v6.0a\include\ws2def.h(384) : error C2143: syntax error : missing ';' before 'constant'
C:\sdk\windows\v6.0a\include\ws2def.h(384) : error C2059: syntax error : 'constant'
C:\sdk\windows\v6.0a\include\ws2def.h(437) : error C2143: syntax error : missing ';' before '}
(...)

Read more…

Synchronizing Google Contacts and Google Calendar in KDE 4

May 2nd, 2010 niels No comments

The support for Google Contacts and Google Calendar in KDE 4.4 is pretty good. All you need is libgcal (sudo apt-get install libgcal0 in Kubuntu). This library provides Akonadi access to your Google account. Once it is installed you just have to configure it in Akonadi, and then you can access your Google contacts and calendar in KMail, KAddressBook, Kontact and Korganizer.

Unfortunately there is no sync option for Akregator and Google Reader yet.

Tags: ,

Consuming pipe Inputs in Unix

March 11th, 2010 niels No comments

You’d like your application to read pipe inputs, like “ls -la | myGreatApp”? That’s pretty easy:

#include <stdio.h>
#include <unistd.h>
 
int main(void)
{
  char input[BUFSIZ];
  /* just read it ... */
  read(STDIN_FILENO, input, BUFSIZ);
  /* ... and use it */
  puts(input);
 
  return(0);
}
Tags: , , ,