Two other useful preprocessor directives are #warning and #error . These will respectively cause awarning or an error to be raised when the compiler encounters them. If the compiler sees a #warning directive, it will display whatever text appears after the #warning to the user, after which compilation
continues. If it encounters a #error directive, it will display the subsequent text to the user as if it were acompilation error message and then immediately abandon the compilation, so no IL code will begenerated.
You can use these directives as checks that you haven ’ t completed anything silly with your #define statements; you can also use the #warning statements to remind yourself to do something:
#if DEBUG & & RELEASE
#error “You’ve defined DEBUG and RELEASE simultaneously!”
#endif
#warning “Don’t forget to remove this line before the boss tests the code!”
Console.WriteLine(“*I hate this job.*”);
0 comments:
Post a Comment