473,473 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Assigned but never used

I am getting the following error (VS2003):

The variable 'ktr' is assigned but its value is never used

How do I tell the compiler to ignore this? You used to have to use a Pragma
statement in C++ to do this.

Thanks,

Tom
Nov 17 '05 #1
8 9172
Hi,

By default this is just a warning, go to Project properties and check in the
Build the status of both "Warning levels " & "Treat warnings as error"

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"tshad" <ts**********@ftsolutions.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
I am getting the following error (VS2003):

The variable 'ktr' is assigned but its value is never used

How do I tell the compiler to ignore this? You used to have to use a
Pragma statement in C++ to do this.

Thanks,

Tom

Nov 17 '05 #2
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ei**************@TK2MSFTNGP12.phx.gbl...
Hi,

By default this is just a warning, go to Project properties and check in
the Build the status of both "Warning levels " & "Treat warnings as error"


There is also a "Suppress specific warnings" setting, which should do the
trick.

Chris Jobson
Nov 17 '05 #3
On Thu, 8 Sep 2005 12:01:02 -0700, "tshad"
<ts**********@ftsolutions.com> wrote:
I am getting the following error (VS2003):

The variable 'ktr' is assigned but its value is never used

How do I tell the compiler to ignore this? You used to have to use a Pragma
statement in C++ to do this.

Thanks,

Tom

You have not shown your code, but it is not in general a good idea to
suppress any warnings. If a variable is assigned and not used then it
is best to rearrange the code so the warning is no longer given. By
suppressing that particular warning you are taking the risk of missing
the same error elsewhere when you amend the code and inadvertently
introduce the same thing in a different part of your code.

rossum

The ultimate truth is that there is no ultimate truth
Nov 17 '05 #4
In my experience such a warning is virtually always a bug in the making so I
would NEVER suppress them or tolerate their presence. Why don't you correct
the code that generates the warning?

Cheers
Doug Forster

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
I am getting the following error (VS2003):

The variable 'ktr' is assigned but its value is never used

How do I tell the compiler to ignore this? You used to have to use a
Pragma statement in C++ to do this.

Thanks,

Tom

Nov 17 '05 #5
"Doug Forster" <doug_ZAPTHIS_AT_ZAPTHIS_TONIQ_DOT_CO_DOT_NZ> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
In my experience such a warning is virtually always a bug in the making so I would NEVER suppress them or tolerate their presence. Why don't you correct the code that generates the warning?
Because this warning is typically for a variable that I am temporarily
using, such as stemp, or itemp for use in testing. I will usually comment
out sections that I may uncomment later.

The variables take up little room and will hurt nothing.

Tom
Cheers
Doug Forster

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
I am getting the following error (VS2003):

The variable 'ktr' is assigned but its value is never used

How do I tell the compiler to ignore this? You used to have to use a
Pragma statement in C++ to do this.

Thanks,

Tom


Nov 17 '05 #6
"tshad" <tf*@dslextreme.com> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl...
"Doug Forster" <doug_ZAPTHIS_AT_ZAPTHIS_TONIQ_DOT_CO_DOT_NZ> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
In my experience such a warning is virtually always a bug in the making
so I
would NEVER suppress them or tolerate their presence. Why don't you

correct
the code that generates the warning?


Because this warning is typically for a variable that I am temporarily
using, such as stemp, or itemp for use in testing. I will usually comment
out sections that I may uncomment later.

The variables take up little room and will hurt nothing.


Also, I know what variables I am going to use, such as paxTotal,
paxSubTotal, paxGrandTotal, but I haven't used them yet. I always put my
variable definitions at the top of the subroutine, so if I know what
variables I will need (such as totaling a large grid), I will usually assign
all the variables when I build the routine.

The problem with these warnings, is I could have 10 or more of them when I
build the project, and is not apparent whether there really is a problem as
the real errors are mixed with the warnings.

Tom
Tom

Cheers
Doug Forster

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
>I am getting the following error (VS2003):
>
> The variable 'ktr' is assigned but its value is never used
>
> How do I tell the compiler to ignore this? You used to have to use a
> Pragma statement in C++ to do this.
>
> Thanks,
>
> Tom
>



Nov 17 '05 #7

"tshad" <ts**********@ftsolutions.com> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
"tshad" <tf*@dslextreme.com> wrote in message news:ul**************@TK2MSFTNGP15.phx.gbl... <snip> Also, I know what variables I am going to use, such as paxTotal, paxSubTotal, paxGrandTotal, but I
haven't used them yet. I always put my variable definitions at the top of the subroutine, so if I
know what variables I will need (such as totaling a large grid), I will usually assign all the
variables when I build the routine.

The problem with these warnings, is I could have 10 or more of them when I build the project, and
is not apparent whether there really is a problem as the real errors are mixed with the warnings.


I generally just comment them out at that point to stop the warning.
When you are ready to use the variable you simply uncomment it.

Bill
Nov 17 '05 #8
"Bill Butler" <qw****@asdf.com> wrote in message
news:DOmUe.175$sa6.24@trndny06...

"tshad" <ts**********@ftsolutions.com> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
"tshad" <tf*@dslextreme.com> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl... <snip>
Also, I know what variables I am going to use, such as paxTotal,
paxSubTotal, paxGrandTotal, but I haven't used them yet. I always put my
variable definitions at the top of the subroutine, so if I know what
variables I will need (such as totaling a large grid), I will usually
assign all the variables when I build the routine.

The problem with these warnings, is I could have 10 or more of them when
I build the project, and is not apparent whether there really is a
problem as the real errors are mixed with the warnings.


I generally just comment them out at that point to stop the warning.
When you are ready to use the variable you simply uncomment it.


I've done the same. I just find it more convenient to list them out and
they are there when necessary.

As I mentioned, I use are temporary variables, such as iktr or itemp or
stemp that are used to quickly test something and I really don't want to
comment and uncomment when needed or not needed. Ans since it causes no
problem, why not.

Tom

Bill

Nov 17 '05 #9

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

Similar topics

8
by: Jason Bell | last post by:
Give the following custom attribute: public class WidgetEventAttribute : System.Attribute { protected Cegui.EventHandler mEventHandler = null; public WidgetEventAttribute( string...
1
by: Hans Nieser | last post by:
I was wondering wether it was normal that I get "field is never assigned to" warnings after defining a struct but not having actually referred to it in my code yet. Is this just something I'll have...
2
by: Andrew Backer | last post by:
I have a series of class variables that are assigned to through reflection. Every time I compile one of these classes I get this warning : warning CS0649: Field 'xxx' is never assigned to, and...
0
by: Michael Howes | last post by:
I have a strange "warning" that shows up during design time in my current project. I have a UserControl, which contains a public enum called ViewTypes This UserControl also has a public property...
2
by: hui | last post by:
Here is a problem I am having with web form designer. I have a database control in the form, and setup the connection string as a dynamic property. It compiles and runs fine. I close the aspx...
0
by: VB Programmer | last post by:
I wanted to access some properties of a panel control that is on a different form. So, I went to the (Declarations) section of my main form (the form with the panel) and changed the panel (called...
4
by: mros | last post by:
I've created three buttons on a form (IsMdiContainer=True), it's mdi parent. I need to disable these buttons from one of my child form. So, I've changed these buttons modifier to Friend Shared...
3
by: emalcolm_FLA | last post by:
Hello and Thanks in advance for any help. I have been tasked with rewriting a christmas assistance database using Access 2003. The old system used pre-assigned case numbers to identify...
17
by: tshad | last post by:
In VS 2008, I have an object, dbReader, that I get a warning saying that it is used before it has been assigned a value. That is correct. Dim dbReader As SqlDataReader and later:
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.