473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

#pragma warning (disable:4214)

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
Dec 13 '05 #1
1 15045
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:

Expand|Select|Wrap|Line Numbers
  1. public struct MyStruct
  2. {
  3. public string Field1, Field2;
  4. }
  5.  
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:

Expand|Select|Wrap|Line Numbers
  1. #pragma warning disable 0649
  2.  
  3. public struct MyStruct
  4. {
  5. public string Field1, Field2;
  6. }
  7.  
  8. #pragma warning restore 0649
  9.  
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.
Sep 4 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Eric Boutin | last post by:
Hi ! currently programming something that heavily use std::vector<std::string> and std::map<std::string, std::string> . When compiling my program I have like 1015 warnings : warning, debug info...
7
by: Nick Butler | last post by:
In C++ there is a very useful function to programatically disable warnings temporarily. Can this be done in C# ?
5
by: Robert A Riedel | last post by:
I have a class that is intended to be exported in a DLL that uses another class that is in a static library. All clients that use the DLL will also link with the same static library. In summary,...
6
by: Kim Hellan | last post by:
I want to suppress the following warning when compiling. warning CS0169: The private field 'myvar' is never used In C++ you would do something like (not sure of the syntax): #pragma nowarn:0169...
2
by: Marco Segurini | last post by:
Hi, I like to know if is it possible to disable/reenable /WX (treat warning as error) via #pragma on my code. TIA. Marco. --
2
by: Siemel Naran | last post by:
I keep getting warning messages like these: ....\include\myfile.h(451) : warning C4251: 'MyClass::m_myvariable' : class 'CPtrArray' needs to have dll-interface to be used by clients of class...
5
by: Tran Hong Quang | last post by:
Hi, I am new to C++. Could someone explain the meaning of below code: # pragma warning(disable : 4786) # define for if(0){}else for Thanks Tran Hong Quang
1
by: przemyslaw.sliwa | last post by:
Hi, I just wanted to write a quick macro, which will wrap the following code #define EXCLUDE_WIN_WARNING(warning_id) \ #ifdef _MSC_VER \ #pragma warning(push) \...
3
by: =?Utf-8?B?S2VuRGV2?= | last post by:
I would like to know if there is a pragma id that I can use to suppress the warning I get (.NET 2.0) for the GetCurrentThreadId. I want to use warnings as errors and I don't want to change the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.