Archiv für September 2008

Backslashes in C includes…

Samstag, 27. September 2008

Who’d have thought:

  1. that DOS backslashes in C include paths aren’t only ugly and a pain, but also not legal* C:

    If the characters ‚, \, „, //, or/* occur in the sequence between the < and > delimiters, the behavior is undefined. Similarly, if the characters ‚, \, //, or /* occur in the sequence between the “ delimiters, the behavior is undefined. A header name preprocessing token is recognized only within a #include preprocessing directive.

    (C99 6.4.7.3)

  2. … the C99 Standard is available for free online This links directly to the pdf containing the current standard, which lives here.
  3. It’s easy to fix:

    find . -name '*.[c|h]' -print0 | xargs -0 \
       ruby -i.bak -pe 'scan(/^\s*#include.*/){ gsub(/\\/, "/") }'
    
  4. * yeah, I know, it’s legal just undefined.
    ** this post inspired by this.

Backing up MacOSX Address Book without MaxOSX Address Book

Dienstag, 9. September 2008

I recently installed a new harddrive on my Macbook. Before proceeding, I made a backup of my entire drive using SuperDuper. I wanted a fresh install, so instead of just dumping the old disk image on the new drive, I installed Leopard and started selectively copying what I needed.

Everything went well until I wanted my Address Book back. Unfortunately, all advice concerning backing up Address Book is along the lines of „Start Address Book and select ‚Back up‘ from the ‚File‘ menu“, but no one tells you where Address Book actually saves the addresses. The easiest way to find out turned out to be using Instruments to monitor what files Address Book opened on startup.

To make a long story short: to transfer entries from one computer to another, just copy the Folder:

/Users/.../Library/Application Support/AddressBook

You may not be able to overwrite some files, because they are in use by other programmes (in my case the culprit was Safari). You can figure out which programme currently has files open using fuser in the Terminal.