31 Dec 2003 Svartalf   » (Journeyer)

Here's a little gem of wisdom that I wish other coders and developers would figure out:

Pointer Values != DWORDs

Reinterpreting them to DWORDs causes no end to problems. Yes, on a 32-bit platform, they're DWORDs. On a 16-bit or 8-bit, they're not- they can either be DWORDs or WORDs depending on architechture. On a 64-bit machine, they're QWORDs. If you want to make a handle, in other words, an opaque pointer, declare a typedef for void * and go to town. If you're recycling something that was intended for use with DWORDs or INT32s to handle indexing or tracking pointers, you might want to take the time to think about and re-think your design to use the right data types.

These are the same silly things that I saw with migrating DOS applications to Windows. It's the same silly things I saw with migrating Win16 to Win32 applications.

It's so easy to write code in a manner to avoid this stuff, I guess that I'm amazed that I keep finding gems like this in modern code.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!