Table of Contents
show
The line directive is used to reset the line number and the file name as reported by __LINE__ and __FILE__ macros. The line directive is used for the purpose of error diagnostics
It has two forms,
#line constant
The line directive of this form causes the compiler to ascertain that the line number of the next source line is equal to the decimal integer constant specified in the directive
#line constant “filename”
The line directive of this form causes the compiler to ascertain that the line number of the next source line is given by the decimal integer constant and the current file is named by the identifier filename specified in the directive
Example
#include<stdio.h>
int main()
{
printf("Line no. is %d, File name is %s \n",__LINE__, __FILE__);
#line 200
printf("Line no. is %d, File name is %s \n",__LINE__, __FILE__);
#line 100 "abc.c"
printf("Line no. is %d, File name is %s \n",__LINE__, __FILE__);
return 0;
}
Output
Line no. is 4, File name is line_.c
Line no. is 200, File name is line_.c
Line no. is 100, File name is abc.c
Views: 0