]> git.sur5r.net Git - cc65/commitdiff
Merge pull request #468 from pmjdebruijn/samples
authorOliver Schmidt <ol.sc@web.de>
Sun, 23 Jul 2017 00:09:20 +0000 (02:09 +0200)
committerGitHub <noreply@github.com>
Sun, 23 Jul 2017 00:09:20 +0000 (02:09 +0200)
make changes

doc/cc65.sgml
src/cc65/pragma.c

index 3689c0b35e37edfe11500b78add6ca88335b67d3..cd94f50acd8d16c3b080033718f99d13dc856fa4 100644 (file)
@@ -1119,6 +1119,23 @@ parameter with the <tt/#pragma/.
   remembered and output as a whole when translation is finished.
 
 
+<sect1><tt>#pragma message (&lt;message&gt;)</tt><label id="pragma-message"><p>
+
+  This pragma is used to display informational messages at compile-time.
+
+  The message intented to be displayed must be a string literal.
+
+  Example:
+  <tscreen><verb>
+        #pragma message ("in a bottle")
+  </verb></tscreen>
+
+  Results in the compiler outputting the following to stderr:
+  <tscreen><verb>
+        example.c(42): Note: in a bottle
+  </verb></tscreen>
+
+
 <sect1><tt>#pragma optimize ([push,] on|off)</tt><label id="pragma-optimize"><p>
 
   Switch optimization on or off. If the argument is "off", optimization is
index d50d151a7c063700590d841c6384f975e17afc54..25bc29d43cdfbfaad8cb6425deaf900c5af46e04 100644 (file)
@@ -78,6 +78,7 @@ typedef enum {
     PRAGMA_DATASEG,                                     /* obsolete */
     PRAGMA_INLINE_STDFUNCS,
     PRAGMA_LOCAL_STRINGS,
+    PRAGMA_MESSAGE,
     PRAGMA_OPTIMIZE,
     PRAGMA_REGISTER_VARS,
     PRAGMA_REGVARADDR,
@@ -114,6 +115,7 @@ static const struct Pragma {
     { "dataseg",                PRAGMA_DATASEG            },      /* obsolete */
     { "inline-stdfuncs",        PRAGMA_INLINE_STDFUNCS    },
     { "local-strings",          PRAGMA_LOCAL_STRINGS      },
+    { "message",                PRAGMA_MESSAGE            },
     { "optimize",               PRAGMA_OPTIMIZE           },
     { "register-vars",          PRAGMA_REGISTER_VARS      },
     { "regvaraddr",             PRAGMA_REGVARADDR         },
@@ -750,6 +752,13 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High)
 
 
 
+static void MakeMessage (const char* Message)
+{
+    fprintf (stderr, "%s(%u): Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message);
+}
+
+
+
 static void ParsePragma (void)
 /* Parse the contents of the _Pragma statement */
 {
@@ -849,6 +858,10 @@ static void ParsePragma (void)
             FlagPragma (&B, &LocalStrings);
             break;
 
+        case PRAGMA_MESSAGE:
+            StringPragma (&B, MakeMessage);
+            break;
+
         case PRAGMA_OPTIMIZE:
             FlagPragma (&B, &Optimize);
             break;