Saturday, 14 September 2013

Output of the #error directive in C

Output of the #error directive in C

I have a piece of code, to throw an error during compilation using the
#error directive to check the chip type present on the board. When I run
it, I get an output on the stdio that is something like below:
errorchk.c:9:2: error: #error "I can't run"
I was expecting to see an error like this:
errorchk.c:9: error: "I can't run"
I'm not able to figure out what is the error in line 12 (if any), that is
shown below.
#include "stdio.h"
#define X 2
void main()
{
int x=6;
if(x>5)
{
#if X>1
#error "I can't run"

No comments:

Post a Comment