Mail Archives: djgpp/2000/08/17/15:00:19
radsmail AT juno DOT com (Radical NetSurfer) wrote in
<1u6ops46pog5cggn1o102tlig0msdqkmeo AT 4ax DOT com>:
>On Wed, 16 Aug 2000 12:36:42 -0400, Radical NetSurfer
><radsmail AT juno DOT com> wrote:
>
>>Does DJGPP suppport __FILE__, __DATE__, __LINE__, etc?
>
>Apparently these do exist, since when I
>#define __FILE__ foo_bar
>I get a re-definition error....
>
>I still have NO CLUE how to get these to display during compile
>times. I think it rediculuous that #message does not exist,
>or that #warning does not expand macro's.
>Thats why people use Borland, etc.
why do you want to display the name of the file you are compiling, and the
date etc?
if there is an error/warning, gcc gives you the information:
C:\tmp>gcc -c c.c -Wall
c.c: In function `main':
c.c:4: warning: `return' with no value, in function returning non-void
(assuming you know the date you are compiling the file).
now, the standard way of using those macros is to convey the module, date,
line information at RUN time (example lifted directly from the CPP
documentationt that Nate mentioned earlier):
fprintf (stderr, "Internal error: "
"negative string length "
"%d at %s, line %d.",
length, __FILE__, __LINE__);
also,
#include <stdio.h>
int main(void) {
return
printf("%s compiled on %s at %s\n", __FILE__, __DATE__, __TIME__);
}
C:\tmp>gcc c.c -o c.exe -Wall
C:\tmp>c
c.c compiled on Aug 17 2000 at 14:57:27
--
--------------------------------
A. Sinan Unur
http://www.unur.com/
- Raw text -