Q:

C# program to demonstrate the #warning preprocessor directive

0

C# program to demonstrate the #warning preprocessor directive

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to demonstrate the #warning preprocessor directive is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//C# program to demonstrate the 
//#warning preprocessor directive.

#define MACRO1
#define MACRO2
#define MACRO3
#undef  MACRO2

using System;

class Program
{
   public static void Main()
   {
        #if (!MACRO2)
            #warning MACRO2 is not defined
        #endif
    }
}

Output:

Warning	1	#warning: 'MACRO2 is not defined'

Explanation:

The above program will generate a warning because here we used the #warning directive with a specified message in the Main() method then the specified message will print as a warning when we compile the program.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now