让C18抛出编译器错误

0 c compiler-errors pic mplab mplab-c18

有没有办法让C18编译器在编译期间抛出自己的自定义错误消息?

例如,考虑具有两个用户定义设置的情况:

#define SETTING_A 0x80
#define SETTING_B 0x3f
Run Code Online (Sandbox Code Playgroud)

假设这些设置不能同时存在 0x00.当用户将两个设置都设置为时,有没有办法让编译器抛出错误(或至少是一个警告)0x00

Ale*_*nze 6

考虑使用#if#error:

#if (SETTING_A == 0) && (SETTING_B == 0)
#error SETTING_A and SETTING_B can't both be 0!
#endif
Run Code Online (Sandbox Code Playgroud)