与升压:: function_types函数调用约定 [英] function calling convention with boost::function_types

查看:149
本文介绍了与升压:: function_types函数调用约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚最近尝试用了boost :: function_types库,并且我已经遇到一个有点暴牙的。我想找出给定函数的调用约定,但我不太知道如何做到这一点。这是我到目前为止有:

这会产生如何,如果语句不能发现里面每个* _cc标记值错误。我怀疑它可能是与我定义宏的方式;该文档不是有关如何使用您的编译器设置额外的调用约定...在这里任何帮助将是AP preciated很清楚。

谢谢,

编辑:得到它的工作,好像我需要包括配置/ config.hpp,如下:

 的#define BOOST_FT_COMMON_X86_CCs 1
#包括LT&;提升/ function_types /配置/ config.hpp>
#包括LT&;升压/ type_traits.hpp>
#包括LT&;升压/ function_types / property_tags.hpp>
#包括LT&;升压/ function_types / is_function.hpp>
#包括LT&;升压/ function_types / is_function_pointer.hpp>
#包括LT&;升压/ function_types / parameter_types.hpp>
#包括LT&;升压/ function_types / result_type.hpp>
#包括LT&;升压/ function_types / function_arity.hpp>模板<类F>
内嵌无效parse_cc(F楼func_info_s&安培;出){
    out.cc = cc_err;
    如果(的boost :: function_types :: is_function< F,stdcall_cc> ::值==真){
        out.cc = cc_stdcall;
    }否则如果(的boost :: function_types :: is_function< F,fastcall_cc> ::值==真){
        out.cc = cc_fastcall;
    }否则如果(的boost :: function_types :: is_function< F,cdecl_cc> ::值==真){
        out.cc = cc_cdecl;
    }
}


解决方案

好像我只是缺少头文件中的一个(配置/ config.hpp)

 的#define BOOST_FT_COMMON_X86_CCs 1
#包括LT&;提升/ function_types /配置/ config.hpp>
#包括LT&;升压/ type_traits.hpp>
#包括LT&;升压/ function_types / property_tags.hpp>
#包括LT&;升压/ function_types / is_function.hpp>
#包括LT&;升压/ function_types / is_function_pointer.hpp>
#包括LT&;升压/ function_types / parameter_types.hpp>
#包括LT&;升压/ function_types / result_type.hpp>
#包括LT&;升压/ function_types / function_arity.hpp>模板<类F>
内嵌无效parse_cc(F楼func_info_s&安培;出){
    out.cc = cc_err;
    如果(的boost :: function_types :: is_function< F,stdcall_cc> ::值==真){
        out.cc = cc_stdcall;
    }否则如果(的boost :: function_types :: is_function< F,fastcall_cc> ::值==真){
        out.cc = cc_fastcall;
    }否则如果(的boost :: function_types :: is_function< F,cdecl_cc> ::值==真){
        out.cc = cc_cdecl;
    }
}

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;
    }
}

解决方案

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;
    }
}

这篇关于与升压:: function_types函数调用约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆