gpt4 book ai didi

c++ - C++ 中函数或类之前的宏是什么?

转载 作者:搜寻专家 更新时间:2023-10-31 00:11:17 25 4
gpt4 key购买 nike

<分区>

我见过这样的代码:

#define A // macro
A void foo(bar); // function declaration

还有这个:

#define B // macro
class B foo { // class declaration
bar
};

在那里使用宏是什么意思?

呃...我的意思是我不明白语法。我以前没见过这个。

其实我只是在opencv3.1的features2d.hpp中找到了这种代码。

class CV_EXPORTS_W BOWImgDescriptorExtractor {
...
CV_WRAP void setVocabulary( const Mat& vocabulary );
...
}

在cvdef.h中

#if (defined WIN32 || defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS
# define CV_EXPORTS __declspec(dllexport)
#elif defined __GNUC__ && __GNUC__ >= 4
# define CV_EXPORTS __attribute__ ((visibility ("default")))
#else
# define CV_EXPORTS
#endif

/* special informative macros for wrapper generators */
#define CV_EXPORTS_W CV_EXPORTS
#define CV_WRAP

这里,CV_EXPORTS_W 和 CV_WRAP 是宏。我在 C++ 中没有看到这种语法。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com