473,406 Members | 2,707 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,406 software developers and data experts.

Disable Warning for Unused Variable

Is there a tag that I can use to designate that a parameter is not used
and thus, not flag a compiler warning?

For example:

public struct MyClass {
public int header;
private int padding_;
}

The compiler complains that padding_ is not used. That is the desired
behavior in that it is used merely as padding in memory. I don't want
to disable all compiler warnings; just this particular instance. Does
C# support this?
Oct 25 '06 #1
2 8757
Hi,

You don't need to add arbitrary properties:

[System.Runtime.InteropServices.StructLayout(
System.Runtime.InteropServices.LayoutKind.Sequenti al,
Size=8)]
public struct MyClass // shouldn't be named Class ;)
{
public int header;
}

--
Dave Sexton

"O.B." <fu******@bellsouth.netwrote in message
news:12*************@corp.supernews.com...
Is there a tag that I can use to designate that a parameter is not used and
thus, not flag a compiler warning?

For example:

public struct MyClass {
public int header;
private int padding_;
}

The compiler complains that padding_ is not used. That is the desired
behavior in that it is used merely as padding in memory. I don't want to
disable all compiler warnings; just this particular instance. Does C#
support this?

Oct 26 '06 #2
#pragma warning disable PUT_WARNING_NUMBER_HERE

public struct MyClass {
public int header;
private int padding_;
}
#pragma warning restore PUT_WARNING_NUMBER_HERE

On Oct 25, 3:37 pm, "O.B." <funkj...@bellsouth.netwrote:
Is there a tag that I can use to designate that a parameter is not used
and thus, not flag a compiler warning?

For example:

public struct MyClass {
public int header;
private int padding_;

}The compiler complains that padding_ is not used. That is the desired
behavior in that it is used merely as padding in memory. I don't want
to disable all compiler warnings; just this particular instance. Does
C# support this?
Oct 26 '06 #3

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

Similar topics

5
by: Jason Heyes | last post by:
This debugger-related warning is flooding my output window. Example: c:\program files\microsoft visual studio\vc98\include\xmemory(38) : warning C4786:...
13
by: HappyHippy | last post by:
Hi, I'm wondering what you think about this piece of code: #include<iostream> int main() { int size; std::cin >> size;
2
by: roni | last post by:
can i set the compiler to give me warning if variable is not used ? ( in VB.NET )
3
by: Tom McL. | last post by:
Is there a way I identify and remove unused variable within vb2005 standard edition
5
by: mario | last post by:
Hi! For reasons that it would be long to explain, I need to use the option /QIfist in VC2005. This gives me the following warning whenever I compile: cl : Command line warning D9035 : option...
2
by: diwadube2003 | last post by:
I get a Warning message while automatically sending email through MS Access, using Outlook. Can anybody help me out with this.
3
by: jaime | last post by:
Hi all. The source code download bundle for "Beginning C: From Novice to Professional, Fourth Edition" (ISBN: 1590597354) (Horton/Apress) contains a C source file (program9_09.c) which contains...
9
by: werasm | last post by:
Hi all, I'm looking for a nice clean (portable) way to get rid of unused variable warnings without fiddling with compiler settings (on a per case basis). I've come up with this: template...
4
by: lovecreatesbea... | last post by:
Gcc only gives out a warning: `assignment discards qualifiers from pointer target type' against code such as following: $ type a.c int main(void) { const char *pc; char *p = pc;
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.