]> git.sur5r.net Git - cc65/commitdiff
Added the __DATE__ and __TIME__ preprocessor macros
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 23 Sep 2002 21:37:15 +0000 (21:37 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 23 Sep 2002 21:37:15 +0000 (21:37 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1403 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/compile.c

index de1144bb0f5c7c6e2c2e9bc02e64269ec926d6d0..d044a09669f0db091010f3a12db2ddf406880d5e 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/* (C) 2000-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
 
 
 #include <stdlib.h>
+#include <time.h>
 
 /* common */
 #include "version.h"
+#include "xmalloc.h"
 
 /* cc65 */
 #include "asmlabel.h"
@@ -255,8 +257,10 @@ static void Parse (void)
 void Compile (const char* FileName)
 /* Top level compile routine. Will setup things and call the parser. */
 {
-    char* Path;
-
+    char*  Path;
+    char   Buf[16];
+    time_t Time;
+    char*  TimeStr;
 
     /* Add some standard paths to the include search path */
     AddIncludePath ("", INC_USER);             /* Current directory */
@@ -293,6 +297,14 @@ void Compile (const char* FileName)
        }
     }
 
+    /* __TIME__ and __DATE__ macros */
+    Time = time (0);
+    TimeStr = ctime (&Time);
+    sprintf (Buf, "\"%.10s\"", TimeStr);
+    DefineTextMacro ("__DATE__", Buf);
+    sprintf (Buf, "\"%.15s\"", TimeStr+11);
+    DefineTextMacro ("__TIME__", Buf);
+
     /* Initialize the literal pool */
     InitLiteralPool ();