Information Technology Reference
In-Depth Information
Line Number Directives
Line number directives can do several things, including the following:
￿
Change the apparent line numbers reported by the compiler's warning and error
messages.
￿
Change the apparent filename of the source file being compiled.
￿
Hide a sequence of lines from the interactive debugger.
The syntax for the #line directives is the following.
#line integer // Sets line number of next line to value of integer
#line " filename " // Sets the apparent filename
#line default // Restores real line number and filename
#line hidden // Hides the following code from stepping debugger
#line // Stops hiding from debugger
The #line directive with an integer parameter causes the compiler to consider that value
to be the line number of the following line of code. Numbering of the subsequent lines contin-
ues, based on that line number.
￿
To change the apparent filename, use the filename, inside double quotes, as the param-
eter. The double quotes are required.
To return to true line numbering, and the true filename, use default as the parameter.
￿
￿
To hide a segment of code from the step-through-code feature of the interactive debugger,
use hidden as the parameter. To stop hiding, use the directive with no parameter. This fea-
ture has, so far, mostly been used in ASP.NET, for hiding compiler-generated code.
The following code shows examples of the line number directives.
#line 226
x = y + z; // Now considered by the compiler to be line 226.
...
#line 330 "SourceFile.cs" // Changes the reported line number and filename.
var1 = var2 + var3;
...
#line default // Restores true line numbers and filename
Search WWH ::




Custom Search