如何使用 BOOST 获得函数调用约定?
使用 BOOST,我试图获取函数的调用约定,为此,我采用了与发布相同问题的人类似的方法 - 但是他们的解决方案并没有解决我的问题。
这是他们问题的链接: 使用 boost::function_types 的函数调用约定
我尝试使用类似的方法获取调用约定,但收到编译器错误,抱怨“cdecl_cc”未定义。这是我的代码的一小段:
#define BOOST_FT_COMMON_X86_CCs 1
#include <boost/function_types/config/config.hpp>
#include <boost/function_types/is_function.hpp>
static bool isCdecl()
{
if(boost::function_types::is_function<T, cdecl_cc>::value == true)
return true;
return false;
}
另一个用户声称通过添加包含到 boost/function_types/config/config.hpp 并定义 BOOST_FT_COMMON_X86_CCs,问题得到了解决 - 但是它还没有解决我的问题。
我也尝试将包含和定义放在预编译头中。
查看 config.hpp 我看到 cc_names.hpp 包含一个包含内容,其中列出了这样的定义,所以
#define BOOST_FT_BUILTIN_CC_NAMES \
(( IMPLICIT , implicit_cc , BOOST_PP_EMPTY ))\
(( CDECL , cdecl_cc , BOOST_PP_IDENTITY(__cdecl ) ))\
(( STDCALL , stdcall_cc , BOOST_PP_IDENTITY(__stdcall ) ))\
(( PASCAL , pascal_cc , BOOST_PP_IDENTITY(pascal ) ))\
(( FASTCALL , fastcall_cc , BOOST_PP_IDENTITY(__fastcall) ))\
(( CLRCALL , clrcall_cc , BOOST_PP_IDENTITY(__clrcall ) ))\
(( THISCALL , thiscall_cc , BOOST_PP_IDENTITY(__thiscall) ))\
(( IMPLICIT_THISCALL , thiscall_cc , BOOST_PP_EMPTY ))
我不确定应该如何解释这样的定义,如果有人可以向我解释它,我也许能够弄清楚如何解决我的问题问题。
抱歉,我提出了所有与 BOOST 相关的问题,我对它还很陌生,我正在一头扎进一个更困难的库中。
谢谢。
Using BOOST, I am trying to get the calling convention of a function, and to do this I am taking a similar approach as the individual who posted the same question - however their solution has not solved my problem.
Heres a link to their problem: function calling convention with boost::function_types
I have attempted to get the calling convention using a similar approach but am getting compiler errors complaining that "cdecl_cc" is not defined. Heres a small snippet of my code:
#define BOOST_FT_COMMON_X86_CCs 1
#include <boost/function_types/config/config.hpp>
#include <boost/function_types/is_function.hpp>
static bool isCdecl()
{
if(boost::function_types::is_function<T, cdecl_cc>::value == true)
return true;
return false;
}
The other user claims that by adding an include to boost/function_types/config/config.hpp and by defining BOOST_FT_COMMON_X86_CCs, there problem was solved - however It has not solved mine.
I've tried placing the includes and the definition inside of a precompiled header as well.
Looking at config.hpp I see an include to cc_names.hpp which lists the definition like so
#define BOOST_FT_BUILTIN_CC_NAMES \
(( IMPLICIT , implicit_cc , BOOST_PP_EMPTY ))\
(( CDECL , cdecl_cc , BOOST_PP_IDENTITY(__cdecl ) ))\
(( STDCALL , stdcall_cc , BOOST_PP_IDENTITY(__stdcall ) ))\
(( PASCAL , pascal_cc , BOOST_PP_IDENTITY(pascal ) ))\
(( FASTCALL , fastcall_cc , BOOST_PP_IDENTITY(__fastcall) ))\
(( CLRCALL , clrcall_cc , BOOST_PP_IDENTITY(__clrcall ) ))\
(( THISCALL , thiscall_cc , BOOST_PP_IDENTITY(__thiscall) ))\
(( IMPLICIT_THISCALL , thiscall_cc , BOOST_PP_EMPTY ))
I am not sure how one should interpret a definition like this, if someone could explain it to me I might be able to figure out how to solve my problem.
Sorry for all the BOOST related questions from me, I am fairly new to it and I am diving head first into one of the more difficult libraries.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您需要使用
boost::function_types 命名空间
来限定cdecl_cc
,并且还#include
。Boost 很棒,但文档有时可能很晦涩。我认为他们倾向于将其编写为标准的一部分,因此名称空间是隐式的。但除非另有说明,否则您应该假设所有内容都在某个命名空间中,无论是
boost
还是更具体的命名空间。I believe you need to qualify
cdecl_cc
with theboost::function_types namespace
, and also#include <boost/function_types/property_tags.hpp>
.Boost is great, but the documentation can at times be obscure. I think they tend to write it as if it was part of the standard, so the namespace is implicit. But unless otherwise specified you should assume everything is in some namespace, either
boost
or a more specific one.