Search code examples
macrospascalline-numbers

Is there an equivalent to C's __LINE__ macro in Pascal?


Is there an equivalent to C's __LINE__ macro in Pascal? Maybe a function?

{ Prints the line number in source file. }
begin
  write(__LINE__)
end.

Is supposed to print:

3

Solution

  • If you're using Free Pascal, you can use: {$I %LINE%}

    I don't know how portable the construct is between existing compilers.