Fix build with GCC6 sandbox/ibaravy/gcc6
authorIvan Baravy <i.baravy@samsung.com>
Thu, 10 Nov 2016 08:39:33 +0000 (11:39 +0300)
committerIvan Baravy <i.baravy@samsung.com>
Fri, 11 Nov 2016 10:14:58 +0000 (13:14 +0300)
Add -P option to GCC preprocessor
Distinguish linemarkers and pragmas (both start with #)

utils/collect-symbols.c

index 9b7b782035a20a0ee883630a0d002cea42fafd29..d4abaffbc8bdc631fe621f62aa0d25708a8fbcb1 100644 (file)
@@ -292,9 +292,9 @@ static int preprocess_file(const char *preproc, const char *file,
         argv[argc++] = "-c";
 
         if (cflags != NULL)
-            snprintf(cmd, sizeof(cmd), "%s %s -E %s", preproc, cflags, file);
+            snprintf(cmd, sizeof(cmd), "%s %s -E -P %s", preproc, cflags, file);
         else
-            snprintf(cmd, sizeof(cmd), "%s -E %s", preproc, file);
+            snprintf(cmd, sizeof(cmd), "%s -E -P %s", preproc, file);
 
         argv[argc++] = cmd;
         argv[argc]   = NULL;
@@ -627,6 +627,11 @@ static int collect_tokens(input_t *in, ringbuf_t *rb, token_t *tokens,
 
             /* extract path name from preprocessor line-markers */
         case '#':
+            if (input_read(in) == 'p') {    /* p for pragma */
+                while((ch = input_read(in)) != '\n' && ch) {}
+                break;
+            }
+            /* not pragma, assume linemarker */
             v = input_parse_linemarker(in, path, sizeof(path));
             if (v != NULL) {
                 tokens[n].type  = TOKEN_LINEMARKER;