如何使用 BOOST 获得函数调用约定?

发布于 2024-12-19 08:26:09 字数 1624 浏览 0 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拧巴小姐 2024-12-26 08:26:09

我相信您需要使用 boost::function_types 命名空间 来限定 cdecl_cc,并且还 #include

Boost 很棒,但文档有时可能很晦涩。我认为他们倾向于将其编写为标准的一部分,因此名称空间是隐式的。但除非另有说明,否则您应该假设所有内容都在某个命名空间中,无论是 boost 还是更具体的命名空间。

I believe you need to qualify cdecl_cc with the boost::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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文