문제

Is there a way to let the C18 compiler throw an own, customized error message during compiling?

For example, consider a situation with two user-defined settings:

#define SETTING_A 0x80
#define SETTING_B 0x3f

Assume these settings can't be both 0x00. Is there a way to let the compiler throw an error (or at least a warning) when the user sets both settings to 0x00?

도움이 되었습니까?

해결책

Consider using #if and #error:

#if (SETTING_A == 0) && (SETTING_B == 0)
#error SETTING_A and SETTING_B can't both be 0!
#endif

다른 팁

I don't know what C18 does or doesn't support, but you should try the #error directive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top