hi folks,
I want to know about this #pragma warning (disable:4214) ..
what exactly such kind of things does.and tell some more about
#pragma how exactly it is useful.
regards,
Maruthi
I see I'm reading your post about 9 months after you posted it, so you probably already have your answer. But just in case you don't...
From what I understand, #pragma directives in general are pre-compiler directives that are specific to a development environment. They provide options in telling the compiler how to compile your code. With your specific example, you are telling the compiler to not generate warnings for warning message 4214.
Let me give you an example. In a C# program I am writing, I declared a structure:
- public struct MyStruct
-
{
-
public string Field1, Field2;
-
}
-
When I build the app, the compiler kept giving me warning message 0649 (the fields are never assigned to and will have always have the default value of null). Well in my app it is perfectly acceptable to have a null. So to shut these warnings off, I enclosed the struct in a #pragma directive:
- #pragma warning disable 0649
-
-
public struct MyStruct
-
{
-
public string Field1, Field2;
-
}
-
-
#pragma warning restore 0649
-
The most important thing there is the last line. In other areas of the app I may want to know about unassigned variables. So shutting off that warning for the entire compilation process would be bad. By encapsulating just that one struct in a disable/restore block, the compiler ignores the warning just while building the struct information.
There are lots of other nifty things you can do with #pragma directives. Dig around on msdn.microsoft.com. There's lots of information there.