[C++-sig] MSVC calling conventions __stdcall, __fastcall, __cdecl and Boost Python

Jeff Brewer jeff at brewer.com
Tue Apr 22 02:26:40 CEST 2003

I am trying to wrap a library that contains methods and functions that
use explicit calling conventions (__stdcall, __fastcall, __cdecl). My
example is this:

#include <boost/python.hpp>
using namespace boost::python;

int __stdcall f()
	return 0;

class dog
	int __stdcall f() { return 0; }


		.def("f", &dog::f)

Apparently, MSVC treats a int (__stdcall *)() as a totally different
type than int (*)() type. To make this work in Boost.Python, I added
some get_signature function templates, I added a couple templates to the
member_function_cast.hpp file and also updated Boost's type_traits
module to recognize int (__stdcall dog::*)() as a valid member function
pointer. All of this stuff has ifdef BOOST_MSVC's around it.

I guess I have two questions. One, is there any way to tell if I missed
anything or is there another way of wrapping my functions besides
writing manual wrappers (my example seems to compile and run)? Two, does
it make sense to incorporate changes like these into Boost and
Boost.Python? This is very compiler specific stuff, but it seems like
anyone wrapping Windows APIs or DLLs that use explicit calling
conventions would run into this problem (I haven't been reading this
group very long, so forgive me if this topic has already been covered).
I'd be happy to contribute my templates.

Thank you,

Jeff Brewer

p.s. I haven't been using Boost Python very long, but I am constantly
amazed at how well it works and from what little I know about how it
works (my brain hurts from looking through the template definitions :).
I also appreciate the help on this mailing list.

More information about the Cplusplus-sig mailing list