Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/129.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 是否可以创建宏以在C/C+;中创建一致的函数声明+;?_C++_Function_Macros_C Preprocessor - Fatal编程技术网

C++ 是否可以创建宏以在C/C+;中创建一致的函数声明+;?

C++ 是否可以创建宏以在C/C+;中创建一致的函数声明+;?,c++,function,macros,c-preprocessor,C++,Function,Macros,C Preprocessor,基本上我想创建一个宏 DECLARE_FUNC(name, arg1) 它将定义函数名和参数名 我曾尝试执行以下操作,但失败了 #define DECLARE_FILTER_FUNC(fname, arg1) (PointCloud<PointXYZ>::Ptr fname(PointCloud<PointXYZ>::Ptr arg1)) 我希望它能扩展到 PointCloud<PointXYZ>::Ptr orcFilterStatOutlierRemo

基本上我想创建一个宏

DECLARE_FUNC(name, arg1)
它将定义函数名和参数名

我曾尝试执行以下操作,但失败了

#define DECLARE_FILTER_FUNC(fname, arg1) (PointCloud<PointXYZ>::Ptr fname(PointCloud<PointXYZ>::Ptr arg1))
我希望它能扩展到

PointCloud<PointXYZ>::Ptr orcFilterStatOutlierRemoval(PointCloud<PointXYZ>::Ptr inputCloud)
{
    return inputCloud;
}
PointCloud::Ptr或FilterStatOutlierRemoving(PointCloud::Ptr inputCloud)
{
返回输入云;
}
当我编译时,我得到

错误:在“(”标记之前需要构造函数、析构函数或类型转换


我不确定我做错了什么,但我想做的是声明一组具有相同声明的筛选函数,以便我可以将它们作为函数指针传递,以获得更通用的功能。

从宏中去掉多余的括号

#define DECLARE_FILTER_FUNC(fname, arg1) PointCloud<PointXYZ>::Ptr fname(PointCloud<PointXYZ>::Ptr arg1)
#define DECLARE_FILTER_FUNC(fname,arg1)PointCloud::Ptr fname(PointCloud::Ptr arg1)

为什么将定义括在括号中?在询问之前,您应该先查看预处理器的输出。是的,我应该这样做。谢谢您提醒我。我很少发现需要这样做。
#define DECLARE_FILTER_FUNC(fname, arg1) PointCloud<PointXYZ>::Ptr fname(PointCloud<PointXYZ>::Ptr arg1)