I have the first line in the file as:
#define DEBUG
In my program I have used this variable as:
#region Preprocessor directives
#if DEBUG
#error DEBUG is defined
#endif
#endregion
I get this error upon compilation: #error: 'DEBUG is defined'.
Am I mistaking anything?
As I already pointed out in the comments, that is exactly what the `#error' preprocessor directive is intended to do. The description on MSDN says:
#error
lets you generate an error from a specific location in your code.
See here on MSDN: https://msdn.microsoft.com/en-us/library/x5hedts0.aspx
So in your case your directive tells the preprocessor to show the error DEBUG is defined
when the DEBUG
symbol is set.