Partager via


#line (Visual J#) 

The #line directive lets you modify the line numbers and, optionally, the file name in the compiler output for errors and warnings.

#line [ number ["file_name"] | hidden | default ]

Parameters

  • Number
    The number you want to specify for the following line in a source code file.
  • file_name(optional)
    The file name you want to appear in the compiler output. By default, the actual name of the source code file is used. The file name must be in double quotation marks (""). You must use the delimiter character '\' for delimiting an actual '\' character when specifying a file path as is done for string literals.
  • hidden
    Hides the successive lines from the debugger until another #line directive is encountered.
  • default
    Resets the line numbering in a file.

Remarks

The #line default directive sets the line number back to the original source line numbering.

The #line hidden directive hides the successive lines from the debugger. When you step through the code, any lines between a #line hidden and the next #line directive, assuming that it is not another #line hidden directive, are stepped over. This option can also be used to allow ASP.NET to differentiate between user-defined and machine-generated code. Although ASP.NET is the primary consumer of this feature, other source generators can use it.

A #line hidden directive does not affect file names or line numbers in error reporting. If the compiler encounters an error in a hidden block, it reports the current file name and line number of the error.

A source code file can have any number of #line directives.

The #line directive might be used by an automated, intermediate step in the build process. For example, if the intermediate step removed lines from the original source code file, but if you still wanted the compiler to generate output based on the original line numbering in the file, you could remove lines and then simulate the original line numbering with #line.

A source code file can have any number of #line directives.

Example

// preprocessor_line.jsl
// compile with: /W:3
public class MyClass2
{
    public static void main(String [] args) 
    {
        #line 200
        int i;   // VJS1493 on line 200
        #line 8 "c:\\hashline\\another_file.jsl"
        char c;   // VJS1493 on line 8 of c:\hashline\another_file.jsl
        #line default
        int r; // VJS1493 on the original source line and file.
    }
}

See Also

Reference

Visual J# Preprocessing Directives