具体可以看:
Linux threading models compared: LinuxThreads and NPTL
http://www.ibm.com/developerworks/linux/library/l-threading.html
glibc已经默认使用 NPTL. 而uclibc现在官方版本还是使用的linuxthread. 要使用nptl,则需要下载nptl分支:
svn://uclibc.org/branches/uClibc-nptl.
#include <stdio.h>
#define DEVICE_NAME "test"
#define dprintk(fmt, ...) \
do{ \
if(1) printf(DEVICE_NAME ": " fmt, \
## __VA_ARGS__); \
}while(0)
#define dprintk1(fmt, ...) \
do{ \
if(1) printf(DEVICE_NAME ": " fmt, \
__VA_ARGS__); \
}while(0)
/* 该宏也可以这样实现. 但其实这里回避了问题. 问题的引入是建立在可变参数部分为可以为空的基础上的,函数的可变参数就是这样的*/
#define dprintk2(...) \
do{ \
if(1) printf(DEVICE_NAME ": " __VA_ARGS__); \
}while(0)
int main(void)
{
dprintk("abc%d\n", 123);
dprintk("abc\n");
#if 0
dprintk1("abc%d\n", 123);
dprintk1("abc\n");//test.c:29: error: expected expression before ')' token
#endif
dprintk2("abc%d\n", 123);
dprintk2("abc\n");
return 0;
}