2009-09-04 30 views
1

最近我剛剛嘗試了boost :: function_types庫,並且遇到了一些問題。我想找出給定函數的調用約定,但我不太確定如何執行此操作。這是我到目前爲止:boost :: function_types函數調用約定

這會產生一個關於如何在每個if語句中找不到* _cc標記值的錯誤。我懷疑它可能與我定義宏的方式有關;文檔不太清楚如何設置額外的調用約定與您的編譯器......任何幫助在這裏將不勝感激。

感謝,

編輯:得到它的工作,好像我需要包括配置/ 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; 
    } 
} 
+0

你可以添加你的編輯作爲答案,所以問題得到一個正確的接受答案?謝謝! – 2009-09-05 15:04:03

+0

我編輯了我的帖子以反映正確的,功能性的(無雙關語意思的)代碼 – Exponent 2009-09-06 05:07:39

+0

您應該將解決方案作爲答案發布,然後接受它。 – GManNickG 2009-09-06 05:34:45

回答

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