Andrew

September 8, 2008

Generating .DLL Wrappers

Filed under: cplusplus,Programming,Win32 — floodyberry @ 5:25 am
Tags: , ,

A while ago I came across Create your Proxy DLLs automatically by Michael Chourdakis. I thought it was a good idea, but had some room for improvement:

  • Having to use an external .exe (dumpbin/tdump) was an unnecessary step, all the information you need is in the PE header!
  • He did not handle wrapping mangled names or forwarding forwards.
  • Generating an actual project instead of a command line compile call would be a lot more useful considering you will want to do some actual coding instead of generating an empty wrapper.
  • His coding style was somewhat awkward and not easy to modify.

With this in mind, I set about writing my own version. (more…)

May 17, 2007

C++ Templates and Class Inheritance

Filed under: cplusplus,Programming — floodyberry @ 1:03 am
Tags: ,

The following code is not legal C++:

template < class type >
struct A {
	void f() {}
	type mX;
};

template < class type >
struct B : public A<type> {
	void g() { mY = ( mX ); f(); }
	type mY;
};

The best part is that unless you know the obscure reason why it is not legal, it appears legal and might even compile and run perfectly depending on which compiler you’re using. Not surprisingly, that is exactly how I ran in to it. I was doing templated class inheritance and thought I was in the clear because everything ran fine with MSVC7.1 and ICC 9, but when I belatedly tried to compile with g++ 3.4.4, I ran in to the following errors: (more…)

April 14, 2007

UTF-8 Conversion Tricks

Filed under: cplusplus,Optimization,Programming — floodyberry @ 3:04 am
Tags: , , ,

UTF-8 is a wonderfully simple encoding format with some very nice properties, but the juggling required to convert to UTF-16, and UTF-32 can be a little tricky and fairly easy to do poorly. This is further compounded by the various error conditions you must keep an eye out for, such as overlong encodings, reserved ranges, surrogate markers, incomplete sequences, and so on.

These are a couple tricks you can employ to hopefully keep the conversion fast and robust.

(more…)

Create a free website or blog at WordPress.com.