Get USB Drive Serial Number on Os X in C++
Getting the serial number for a USB Serial drive on Os X is tricky just like it is to get a USB serial number on Windows. We want to get the serial number of a USB Flash disk that is…
Overloading Global operator new and delete
Programmers are often advised not to overload global operator new, and to stick to overloading just class specific operator new. The arguments against are many, but they basically boil down to that it is difficult to do it correctly. But…
Get USB Drive Serial Number on Windows in C++
Getting the serial number of a USB device in Windows is a lot harder than it should be. ( But it’s a lot easier than getting the USB serial number on Os X!) It is relatively simple to get USB…
Pseudo Functors and Template Magic
A functor is an object that works like a function. That is it overloads operator(). They are useful when you need to create a series of functions each of which works mostly the same way, but you want that instance…
Implementing Portable Threads and Mutexes
Implementing a portable framework for multi-threading doesn’t have to be difficult or error prone. With the right framework, implementing multi-threaded programs can be pretty simple, and you can hide all the platform dependent functions. You can also implement your threading…
Generating 64-bit Random Numbers in a Given Range
There are good standard ways of generating 32-bit random numbers. If you need something really simple, it is possible for example to generate decent random numbers with a Linear Congruential Random Number Generator:
Using BerkeleyDB to Store Serialized Objects in C++
I’ve been working on a C++ interface to Berkeley DB to support some ongoing projects. The goal is to create an interface that allows me to store serialized C++ objects in a database. Each object is flattened into a text…
Link Errors Compiling MySQL C++ Programs on 64-bit Windows
I’m starting to code up a simple MySql connector class. Here is the code for the class. First the header:
Generate Stack Traces on Crash Portably in C++
There are three basic steps to getting this done, trapping signals, getting the stack frames, and then demangling the c++ symbols. Trapping Signals When a program crashes the operating system will sent it a signal, to give it one last…