Grant Jacobs wrote:
At 2:14 PM +0200 24/6/03, Emil Jerabek wrote:
On Tue, Jun 24, 2003 at 07:52:44PM +0800, Peter N Lewis wrote:
In Metrowerks Pascal, there is a compiler "variable" that has the name of the source file (SrcFile, String) and the current line number (SrcLine, Integer), which can be quite useful for debugging.
Is there an equivalent in GPC?
GPC preprocessor provides magic "macros" __FILE__ and __LINE__.
And also __func__ ? (As in C99...)
`CurrentRoutineName' (which is no macro, but a magic "function" yielding a string constant(!); this is because it's handled by the compiler, not the preprocessor, but for most purposes, it should appear mostly the same as a macro).
These are the three I use to build my C99 assert() function and some other tracing stuff.
It's not really necessary. GPC has a built-in `Assert' procedure which in case of failure gives a regular runtime error. Runtime errors contain the code position which can be converted to a source position using `addr2line'. Using the runtime option `--gpc-rts=-E' or `--gpc-rts=-F', you can also get a call trace in case of runtime error. The script `gpc-run' automatizes this.
Frank