I have been working on Gjay to add support for [Music Player Daemon](http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki) where I had what initially looked like a strange problem. When WITH_MPDCLIENT was defined, the program would crash in all sorts of wierd places when the main program structure had this:
#ifdef WITH_MPDCLIENT struct mpd_connection *mpdclient_connection; #endif /* WITH_MPDCLIENT */
But would work fine when it was:
struct mpd_connection *mpdclient_connection; #ifdef WITH_MPDCLIENT #endif /* WITH_MPDCLIENT */
I tried changing the structure to just void *blah to see if it made a difference and it didn’t. The program would crash every time.
The answer was pretty simple in the end. The WITH_MPDCLIENT is defined in the file config.h and not every c source file was including it. Needless to say, they should! So half the program was using one version of the structure and the other was using another; no wonder the whole program was a mess because anything beyond this entry in the structure would be a few bytes out.
With that little insanity out of the way i can get back to making gjay work with mpd.