先说原因再说结果:
##是个ANSI C99的标准预处理宏,其意思就是将前后两个字符串连接成为一个字符串,比如a##b就是ab,当然,这只发生在编译的预处理宏替换阶段,是个纯文本过程。这个技巧应用还是相当广泛的。
这个问题的结果,你其实完全可以自己搞定的,方法:
gcc -E xxx.c -o xxx.i,执行预处理阶段,然后看生成xxx.i就知道宏替换的结果了。
ICV_DEF_INIT_ARITHM_FUNC_TAB(Sub,C1R)替换之后就是:
static void icvInitSubC1RTable( CvFuncTable* tab )
{
tab->fn_2d[CV_8U] = reinterpret_cast<void*>(icvSub_8u_C1R);
tab->fn_2d[CV_8S] = 0;
tab->fn_2d[CV_16U] = reinterpret_cast<void*>(icvSub_16u_C1R);
tab->fn_2d[CV_16S] = reinterpret_cast<void*>(icvSub_16s_C1R);
tab->fn_2d[CV_32S] = reinterpret_cast<void*>(icvSub_32s_C1R);
tab->fn_2d[CV_32F] = reinterpret_cast<void*>(icvSub_32f_C1R);
tab->fn_2d[CV_64F] = reinterpret_cast<void*>(icvSub_64f_C1R);
}
#define ICV_DEF_INIT_ARITHM_FUNC_TAB( FUNCNAME, FLAG ) \\
static void icvInit##FUNCNAME##FLAG##Table( CvFuncTable* tab )\\
{ \\
tab->fn_2d[CV_8U] = reinterpret_cast<void*>(icv##FUNCNAME##_8u_##FLAG); \\
tab->fn_2d[CV_8S] = 0; \\
tab->fn_2d[CV_16U] = reinterpret_cast<void*>(icv##FUNCNAME##_16u_##FLAG); \\
tab->fn_2d[CV_16S] = reinterpret_cast<void*>(icv##FUNCNAME##_16s_##FLAG); \\
tab->fn_2d[CV_32S] = reinterpret_cast<void*>(icv##FUNCNAME##_32s_##FLAG); \\
tab->fn_2d[CV_32F] = reinterpret_cast<void*>(icv##FUNCNAME##_32f_##FLAG); \\
tab->fn_2d[CV_64F] = reinterpret_cast<void*>(icv##FUNCNAME##_64f_##FLAG); \\
}
ICV_DEF_INIT_ARITHM_FUNC_TAB(Sub,C1R)
ICV_DEF_INIT_ARITHM_FUNC_TAB(SubRC,C1R)
ICV_DEF_INIT_ARITHM_FUNC_TAB(Add,C1R)
ICV_DEF_INIT_ARITHM_FUNC_TAB(AddC,C1R)
下面四句替换过后的是什么?只写一个语句的宏替换就可以了,谢谢各位有心人. |