Unreferenced variable: Difference between revisions

Content deleted Content added
Cydebot (talk | contribs)
m Robot - Speedily moving category Variable (computer programming) to Category:Variable (computer science) per CFDS.
Citation bot (talk | contribs)
Alter: url. URLs might have been anonymized. Add: authors 1-1. Removed parameters. Some additions/deletions were parameter name changes. | Use this bot. Report bugs. | Suggested by AManWithNoPlan | #UCB_CommandLine
 
(14 intermediate revisions by 7 users not shown)
Line 1:
{{Short description|Variable which is defined but never used}}
{{Unreferenced|date=February 2007}}
An '''unreferenced variable''' in the [[source code]] of a [[computer program]] is a [[Variable (programming)|variable]] that is defined but which is never used. This may result in a harmless waste of memory. (unless theMany [[compiler]]s useddetect detectssuch the situationvariables and doesdo not allocate storage for thethem variable(i.e., "optimize away" their storage), perhapsgenerally also issuing a warning) as they do.<ref>{{Cite book Some|last1=Blair-Chappell [[coding|first1=Stephen style|codingurl=https://books.google.com/books?id=n3DtR4mQNmwC guideline]]|title=Parallel documentsProgramming considerwith anIntel unreferencedParallel variableStudio toXE be|last2=Stokes a|first2=Andrew symptom|date=2012-04-19 of|publisher=John aWiley potential& codingSons fault.|isbn=978-1-118-23488-4 |pages=108 |language=en}}</ref>
 
Some [[coding style|coding guideline]] documents consider an unreferenced variable to be a symptom of a potential coding fault. On the other hand, unreferenced variables can be used as temporary placeholders to indicate further expected future developments in the code.
 
==Examples==
[[C (programming language)|C]]:
<sourcesyntaxhighlight lang="c">
int main(void)
{
Line 12 ⟶ 14:
return 0;
}
</syntaxhighlight>
</source>
In this example, '''j''' is an unreferenced variable.
 
<!-- Do not add the References section until references are used in the article. -->
<!-- == References == -->
{{Reflist}}