473,499 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

#pragma warning

In C++ there is a very useful function to programatically disable warnings
temporarily.

Can this be done in C# ?
Nov 15 '05 #1
7 8765
Yes, in VS.NET under project properties-->Configuration Properties-->Build
you can change the warning level and/or list specific warnings to be
ignored. In the command-line use the /warn: and /nowarn: switches to
specify.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Nick Butler" <Ni************@btinternet.com> wrote in message
news:eD*************@TK2MSFTNGP11.phx.gbl...
In C++ there is a very useful function to programatically disable warnings
temporarily.

Can this be done in C# ?

Nov 15 '05 #2
The key word I think was "programatically"

Possibly an attribute class
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Yes, in VS.NET under project properties-->Configuration Properties-->Build
you can change the warning level and/or list specific warnings to be
ignored. In the command-line use the /warn: and /nowarn: switches to
specify.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Nick Butler" <Ni************@btinternet.com> wrote in message
news:eD*************@TK2MSFTNGP11.phx.gbl...
In C++ there is a very useful function to programatically disable warnings temporarily.

Can this be done in C# ?


Nov 15 '05 #3
In addition to the information Richard gave, If you're looking for a
straight #pragma alternative, you're out of luck.

For a list of currently supported "preprocessor directives" (the c# compiler
doesn't actually have a preprocessor, but hey), look here:
http://msdn.microsoft.com/library/de...Directives.asp
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Yes, in VS.NET under project properties-->Configuration Properties-->Build
you can change the warning level and/or list specific warnings to be
ignored. In the command-line use the /warn: and /nowarn: switches to
specify.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Nick Butler" <Ni************@btinternet.com> wrote in message
news:eD*************@TK2MSFTNGP11.phx.gbl...
In C++ there is a very useful function to programatically disable warnings temporarily.

Can this be done in C# ?


Nov 15 '05 #4
I guess in that case I should have said: "No, not programmatically, but..."

Mea Culpa,
Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
<.> wrote in message news:uA**************@TK2MSFTNGP11.phx.gbl...
The key word I think was "programatically"

Possibly an attribute class
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Yes, in VS.NET under project properties-->Configuration Properties-->Build
you can change the warning level and/or list specific warnings to be
ignored. In the command-line use the /warn: and /nowarn: switches to
specify.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Nick Butler" <Ni************@btinternet.com> wrote in message
news:eD*************@TK2MSFTNGP11.phx.gbl...
In C++ there is a very useful function to programatically disable

warnings temporarily.

Can this be done in C# ?



Nov 15 '05 #5

Hi Nick,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you want to find the #pargma diretives
alternative in C#.
=================================================
In C#, there are many directives you can specify in your code, you can find
these directives in C# language specification, please refer to Philip's
reply.

For your concern of #pargma warnning directive, I think you need the
"#warning directives", please refer to:
http://msdn.microsoft.com/library/de...us/csref/html/
vclrfwarning.asp

=================================================
Please apply my suggestion above and let me know if it meets your need.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6
Thanks for your help, everyone.

I guess the answer is "no" !

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:LF**************@cpmsftngxa07.phx.gbl...

Hi Nick,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you want to find the #pargma diretives
alternative in C#.
=================================================
In C#, there are many directives you can specify in your code, you can find these directives in C# language specification, please refer to Philip's
reply.

For your concern of #pargma warnning directive, I think you need the
"#warning directives", please refer to:
http://msdn.microsoft.com/library/de...us/csref/html/ vclrfwarning.asp

=================================================
Please apply my suggestion above and let me know if it meets your need.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #7

Hi Nick,

Thanks for your feedback.

Oh,sorry, I think I provide the wrong #pragma warning alternative to you.
Let me correct it.

===========================================
To control the warning level in C#, you can use 2 compile options to get
this done: /warn and /nowarn
/warn gives you 5 level warning control on code, while /nowarn option
allows you to suppress A warning number.

http://msdn.microsoft.com/library/de...us/cscomp/html
/vcrefwwarninglevel.asp
http://msdn.microsoft.com/library/de...us/cscomp/html
/vcerrNowarnSuppressSpecifiedWarnings.asp

Visual Studio.Net does not expose the function of specifying these 2
options in C# code. But it allows you to specify through IDE macro with
property WarningLevel and NoWarn, for more information, please refer to:
http://msdn.microsoft.com/library/de...us/vbcon/html/
vbgrfnowarnproperty.asp
http://msdn.microsoft.com/library/de...us/vbcon/html/
vxlrfvslangprojprojectconfigurationpropertieswarni nglevel.asp

So you can not get this done directly through your C# code in Visual
Studio.Net 2003.
============================================
If you have any further concern, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2144
by: Jacob Jensen | last post by:
Hi I have a problem creating C++ code that is multiplatform compilable. My problem is using the "#pragma once" directive which can be used by microsoft Visual Studio pre-compiler but which gives...
6
6561
by: Stefan Slapeta | last post by:
The following linker directive #pragma comment (linker, "/delayload:xy.dll") which was valid in VC 6 produces just a warning in VC 7.1 (though the directive is ok, IMO). Is this fixed in...
2
1175
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. --
5
1598
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
5
4931
by: chris_doran | last post by:
/COMMENT has been removed from the linker that comes with VS2005, and use in source code of: #pragma comment(exestr, "this is a string") gives the message: warning LNK4224: /COMMENT is no...
1
6551
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
3880
by: Subrat | last post by:
Hello, I have used #pragma once in a header file. During compilation I get a warning : #pragma once is obsolete. How do I switch off this warning, without making any change to my make file? ...
4
2354
by: dissectcode | last post by:
Hello - Is there a pragma directive that will make a function be ignored? I have a function that is not currently being used and it creates a warning. I would like to fix the warning by using pragma,...
3
3772
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
7130
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
7007
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...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.