预处理指令
1、#error
#error "Please select first the target STM32L4xx device used in your application (in stm32l4xx.h file)"
#error 指令让预处理器发出一条错误信息,并且会中断编译过程。
#error的例子:
#include <stdio.h>
#define RX_BUF_IDX 100
#if RX_BUF_IDX == 0
static const unsigned int rtl8139_rx_config = 0;
#elif RX_BUF_IDX == 1
static const unsigned int rtl8139_rx_config = 1;
#elif RX_BUF_IDX == 2
static const unsigned int rtl8139_rx_config = 2;
#elif RX_BUF_IDX == 3
static const unsigned int rtl8139_rx_config = 3;
#else
#error "Invalid configuration for 8139_RXBUF_IDX"
#endif
int main(void)
{
printf("hello world\n");
return 0;
}
|