views:

167

answers:

1

Hey there,

I've just been experimenting with the boost::function_types library recently, and I've come across a bit of a snag. I want to find out the calling convention of a given function, however I'm not quite sure how to do this. Here's what I have so far:

This produces an error about how it cannot find the *_cc tag values inside each if statement. I suspect it may have something to do with the way I'm defining the macros; the documentation isn't very clear about how to setup extra calling conventions with your compiler... Any help here would be appreciated.

Thanks,

EDITED: got it working, seems like I needed to include config/config.hpp, as below:

#define BOOST_FT_COMMON_X86_CCs 1
#include <boost/function_types/config/config.hpp>
#include <boost/type_traits.hpp>
#include <boost/function_types/property_tags.hpp>
#include <boost/function_types/is_function.hpp>
#include <boost/function_types/is_function_pointer.hpp>
#include <boost/function_types/parameter_types.hpp>
#include <boost/function_types/result_type.hpp>
#include <boost/function_types/function_arity.hpp>

template<class F>
inline void parse_cc(F f, func_info_s& out) {
    out.cc = cc_err;
    if (boost::function_types::is_function<F, stdcall_cc>::value == true) {
        out.cc = cc_stdcall;
    } else if (boost::function_types::is_function<F, fastcall_cc>::value == true) {
        out.cc = cc_fastcall;
    } else if (boost::function_types::is_function<F, cdecl_cc>::value == true) {
        out.cc = cc_cdecl;
    }
}
A: 

It seems like I was simply missing one of the header files (config/config.hpp)

#define BOOST_FT_COMMON_X86_CCs 1
#include <boost/function_types/config/config.hpp>
#include <boost/type_traits.hpp>
#include <boost/function_types/property_tags.hpp>
#include <boost/function_types/is_function.hpp>
#include <boost/function_types/is_function_pointer.hpp>
#include <boost/function_types/parameter_types.hpp>
#include <boost/function_types/result_type.hpp>
#include <boost/function_types/function_arity.hpp>

template<class F>
inline void parse_cc(F f, func_info_s& out) {
    out.cc = cc_err;
    if (boost::function_types::is_function<F, stdcall_cc>::value == true) {
        out.cc = cc_stdcall;
    } else if (boost::function_types::is_function<F, fastcall_cc>::value == true) {
        out.cc = cc_fastcall;
    } else if (boost::function_types::is_function<F, cdecl_cc>::value == true) {
        out.cc = cc_cdecl;
    }
}
Exponent