Subject: Re: gcc Q - a bit off topic
To: Bill Studenmund <skippy@macro.stanford.edu>
From: Jeremy Cooper <jeremy@broder.com>
List: current-users
Date: 10/21/1997 20:10:47
On Tue, 21 Oct 1997, Bill Studenmund wrote:

> I want to turn the call to the addref and delref functions into macros,
> and print out what source file they were called from. Does anyone know how
> to do this? I.E. is there a variable in gcc which is the name of the
> source file being compiled? Or anything else which would help?

ANSI C defines two pre-processor variables which you should find helpful. 
The first is "__LINE__", which is expanded into the current line number in
the file.  The second is "__FILE__" which expands into the current
filename in a quoted string.  Unfortunately, the behavior of __LINE__ was
defined as ``implementation specific'' (i.e. non-standard), but I believe
GCC does what you expect. 

-J