shaswat
Advanced Member level 4
- Joined
- Jul 2, 2013
- Messages
- 115
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 18
- Activity points
- 963
I works on Keil uVision 4 compiler and I found an error during writing my code. I stucked there more than an hour but I didn't resolve the problem. After several Hit and trial I resolve my problem but still I don't know what was the problem. I debug the code in same format in my code-block and found same error as in Keil compiler.
Here is the piece of code....
error: 'else' without a previous 'if'| ( in my code block)
I don't understand why its not working as after if statement ,there is only one instruction so I don't add braces. In that case it shows error. But if I add braces in my statements it works good. Can anybody tell the reason that why adding braces runs the code?
Any new idea would be really appreciated...
Here is the piece of code....
Code:
#define not() printf("if\n");
#define yes() printf("else\n");
int main()
{
uint16_t no ;
if(no)
//{
not();
// }
else
// {
yes();
//}
return 4;
}
error: 'else' without a previous 'if'| ( in my code block)
I don't understand why its not working as after if statement ,there is only one instruction so I don't add braces. In that case it shows error. But if I add braces in my statements it works good. Can anybody tell the reason that why adding braces runs the code?
Any new idea would be really appreciated...