连字符,double pound

来源:互联网 发布:东方中原电子白板软件 编辑:程序博客网 时间:2024/05/16 08:17
逻辑上能解决,多写点代码也是可以理解的。只有不断的学习进步才能把生僻变为不生僻。
注意这样的写法:
//================
#define FUNCTION( arg ) Hello##arg##world

typedef void (*FunctionPoint)( char* parg );
FunctionPoint g_FunctionPoint;

void Hello_world( char* pS )
{
    strcpy( pS, "Hello, world!\n" );

    return;
}

int main(int argc, _TCHAR* argv[])
{
    // get function point
    g_FunctionPoint = FUNCTION(_);
    char sS[ 128 ];

    g_FunctionPoint( sS );
    printf( sS );

    getchar();
    return 0;
}

//================
OUTPUT:
Hello,world!
//================

## 代表的是连字符,double pound。不过现在不太常使用。

g_FunctionPoint = FUNCTION(_);
展开后是:
g_FunctionPoint = Hello_world;
进行了函数指针的赋值。