Example of #line Directives

The following program uses #line control directives to give each function an easily recognizable line number:

/* This example illustrates #line directives. */

#include <stdio.h>
#define LINE200 200

int main(void)
{
 func_1();
 func_2();
}

#line 100
func_1()
{
 printf("Func_1 - the current line number is %d\n",__LINE__);
}

#line LINE200
func_2()
{
 printf("Func_2 - the current line number is %d\n",__LINE__);
}

This program produces the following output:

  Func_1 - the current line number is 102
  Func_2 - the current line number is 202