# Line is used to change the current row number and file name

Source: Internet
Author: User

# Line is used to change the current number of lines and file names. It is the basic form of the pre-defined identifier commands in the Compilation Program as follows:
# Line number ["FILENAME"]
The file name in [] can be omitted. For example:
# Line 30 a.h
The file name a. h can be omitted without writing.


This command can change the current row number and file name. For example, the preceding preprocessing command can change the current row number to 30 and the file name to A. H. It seems to be useless at first, but it is still a bit useful, that is, it is used in the compilation of the compiler. We know that the compiler will generate some intermediate files during the compilation of C source code, this command ensures that the file name is fixed and will not be replaced by these intermediate files, which is conducive to analysis.

 

If # line 100 "other_file" is added to the program, will the program execute the 100 lines of code in other_file?

You can give it a try. How can you become a master?

 

About # Line
Command # line changes the content of _ line _ and _ file _, which are pre-defined identifiers in the Compilation Program.
The basic command format is as follows:
# Line number ["FILENAME"]
The number is a positive integer, and the optional file name is any valid file identifier. The row number is the current
The row number. The file name is the name of the source file. Command # l I n e is mainly used for debugging and other special applications.
For example, the following shows that the row count starts from 1 0 0; the number of printf () statements is 1 0 2, because it is after the statement # line 100
3rd rows.
# Line 100/* initialize the row counter */
Main ()/* row number 100 */
{/* Row number 101 */
Printf ("% d \ n" _ line _);/* row number 102 */
}

Then it's easy to understand.

 

 

#include <stdio.h>#include <stdlib.h>int main(void)
{printf("current line number %d ,current file %s\n",__LINE__,__FILE__);
# line 100 "other_file"
printf("current line number %d ,current file %s\n",__LINE__,__FILE__);
return 0;}

 

It's just for convenience of debugging.
_ Line _ file _ output the row and file where the current code is located. When the program is very complex, errors occur during running and the row numbers are easy to locate when the error message is printed.
_ Function _ name of the current output function
The _ date _ macro command contains a string in the form of month, day, or year, which indicates the date when the source file was translated to the code.
The _ time _ macro command contains the program Compilation Time. Time is represented by a string in the form of minute: Second

 

Others: error, Pragma, line preprocessing

 

# Line is used to change the current row number and file name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.