使用boost :: function_types调用约定的函数

时间:2009-09-04 22:30:39

标签: c++ boost calling-convention

我最近刚刚尝试过boost :: function_types库,而且我遇到了一些障碍。我想找出给定函数的调用约定,但是我不太清楚如何做到这一点。这是我到目前为止所做的:

这会产生关于如何在每个if语句中找不到* _cc标记值的错误。我怀疑它可能与我定义宏的方式有关;文档不是很清楚如何使用您的编译器设置额外的调用约定...这里的任何帮助将不胜感激。

谢谢,

编辑:让它工作,似乎我需要包含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;
    }
}

1 个答案:

答案 0 :(得分:0)

好像我只是缺少一个头文件(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;
    }
}