    Hello all,

    Attached is patch for files tcctok.h and tccpp.c which implements
    '#pragma comment(lib,...)'. Example: #pragma comment(lib,"foo") will
    link the library 'foo' as if specified by -lfoo Note that
    -fms-extensions must be included on the command line, or the #pragma
    will be ignored.


diff -urN tinycc.old/tcc.c tinycc/tcc.c
--- tinycc.old/tcc.c	2015-04-12 15:39:21.000000000 +0300
+++ tinycc/tcc.c	2015-04-14 08:47:57.634254646 +0300
@@ -317,7 +317,7 @@
         const char *filename = s->files[i] + 1;
         if (filename[0] == '-' && filename[1] == 'l') {
             if (tcc_add_library(s, filename + 2) < 0) {
-                tcc_error_noabort("cannot find '%s'", filename);
+                tcc_error_noabort("cannot find '%s'", filename+2);
                 ret = 1;
             }
         } else {
diff -urN tinycc.old/tccpp.c tinycc/tccpp.c
--- tinycc.old/tccpp.c	2015-04-12 15:31:51.000000000 +0300
+++ tinycc/tccpp.c	2015-04-14 08:37:01.183219723 +0300
@@ -1420,7 +1420,25 @@
             *s1->pack_stack_ptr = val;
             skip(')');
         }
+    } else if (tok == TOK_comment) {
+        if (s1->ms_extensions) {
+            next();
+            skip('(');
+            if (tok == TOK_lib) {
+                next();
+                skip(',');
+                if (tok != TOK_STR)
+                    tcc_error("invalid library specification");
+                tcc_add_library(s1,(char *)tokc.cstr->data);
+                next();
+                tok = TOK_LINEFEED;
+            }
+        }
+        else
+            tcc_warning("#pragma comment(lib) is ignored");
     }
+    else
+        tcc_warning("unknown #pragma statement");
 }
 
 /* is_bof is true if first non space token at beginning of file */
diff -urN tinycc.old/tcctok.h tinycc/tcctok.h
--- tinycc.old/tcctok.h	2015-04-12 04:46:13.000000000 +0300
+++ tinycc/tcctok.h	2015-04-13 06:11:26.000000000 +0300
@@ -153,6 +153,9 @@
      DEF(TOK_ASM_push, "push")
      DEF(TOK_ASM_pop, "pop")
 #endif
+      /* pragma comment & comment(lib,...) */
+      DEF(TOK_comment, "comment")
+      DEF(TOK_lib, "lib")
 
 /* builtin functions or variables */
 #ifndef TCC_ARM_EABI
