1

Use of void in C prototypes

A giant died this morning. My condolences go to Dennis Ritchie’s family and friends.

In memory of Dennis, here is a short history lesson about C prototypes. Have you ever wondered why the following is legal?

#include <stdio.h>;

void foo () {
    printf("Goodbye, World!\n");
}

int main (int argc, char **argv) {
    foo(1); /* Call foo with a non-existent parameter */
    return 0;
}

---------------
$ gcc test.c -Wall -Werror
$ ./a.out
Goodbye, World!

This is legal for historical reasons. In pre-ANSI C function prototypes didn’t include parameters. C89 introduced parameters in prototypes, but it continued to recognize the old syntax for backwards compatibility.

If you want to declare a function foo that really takes no parameters, use void:

void foo (void);
1

Installing lxml on Leopard

I’m surely the last developer using Leopard, but Snow Leopard couldn’t compete with Ubuntu and Lion has more warts than the Wicked Witch of the West.

Anyway, you can’t just install lxml with pip (the preferred way of installing Python libraries) because lxml depends on a recent version of libxml2. If you try, gcc will stop when it encounters missing headers added in later versions of libxml2:

libxml/schematron.h: No such file or directory blah blah blah

Instead, use the fabulous Homebrew to install a newer version of libxml2 and then run pip with that version.

brew install libxml2
pip install lxml --install-option="--with-xml2-config=/usr/local/Cellar/libxml2/2.7.8/bin/xml2-config"