在Linux和u-boot源码里面,经常看到 #ifdef 和 #if defined ( ) 的用法:
#include <stdio.h>
#define hello_world
int main( void )
{
#if defined ( hello_world )
printf ( "hello world is defined.\n" );
#endif
#ifdef hello_world
printf ( "hello world is defined.\n" );
#endif
return 0;
}
执行结果:
hello world is defined.
hello world is defined.
总结: