c++ - #define macro() <...> 做什么?

标签 c++ boost macros c-preprocessor

这条线是做什么的? 我怀疑它是一个模板或表达式。 (做那些事并命名一个成员 hpp 是个坏主意)

# define BOOST_PP_UPDATE_COUNTER() <boost/preprocessor/slot/detail/counter.hpp>

完整文件

# /* **************************************************************************
#  *                                                                          *
#  *     (C) Copyright Paul Mensonides 2005.                                  *
#  *     Distributed under the Boost Software License, Version 1.0. (See      *
#  *     accompanying file LICENSE_1_0.txt or copy at                         *
#  *     http://www.boost.org/LICENSE_1_0.txt)                                *
#  *                                                                          *
#  ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# ifndef BOOST_PREPROCESSOR_SLOT_COUNTER_HPP
# define BOOST_PREPROCESSOR_SLOT_COUNTER_HPP
#
# include <boost/preprocessor/slot/detail/def.hpp>
#
# /* BOOST_PP_COUNTER */
#
# define BOOST_PP_COUNTER 0
#
# /* BOOST_PP_UPDATE_COUNTER */
#
# define BOOST_PP_UPDATE_COUNTER() <boost/preprocessor/slot/detail/counter.hpp>
#
# endif

最佳答案

Apparently it does some auto-incrementing magic.

这是 the documentation .

我不知道它是如何工作的。我所知道的是,魔法就在 counter.hpp 本身;你发布的定义中有括号只是为了让你可以写出模糊的用户友好:

#include BOOST_PP_UPDATE_COUNTER()

调用所述魔法。

关于c++ - #define macro() <...> 做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6212476/

相关文章:

c++ - 错误 : invalid initialization for struct in C++

c++ - 具有相交多边形边信息的多边形和线段的交集

c++ - 如何使用 Visual Studio 2022(预览版 3)编译 Boost 库

c++ - 带有多个括号的宏

c - 需要帮助将 C 宏重写为函数

c++ - vector 不增加值(value)

c++ - 用合适的系统调用替换 linux 中的 ftime() 系统调用

c++ - 将 C 字符串分配给指向字符的指针 - C++ 程序崩溃

c++ - 通过组合的数学 vector 类

我可以有一个接受未定义数量参数的 C 宏吗?