[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CEDET calls cpp -E -dM -x c++ /dev/null
From: |
Lennart Borgman |
Subject: |
Re: CEDET calls cpp -E -dM -x c++ /dev/null |
Date: |
Fri, 3 Jul 2009 03:13:12 +0200 |
On Fri, Jul 3, 2009 at 2:46 AM, Miles Bader<address@hidden> wrote:
> Lennart Borgman <address@hidden> writes:
>> Thanks, there are more env vars for this, see
>> http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
>>
>> From the page http://www.mingw.org/wiki/IncludePathHOWTO it looks like
>> the way to get the include path used by gcc is something like
>>
>> touch temp.c
>> gcc -v -c temp.c -o NUL (or /dev/null)
>
> Better to use something like this: gcc -v -E -x c /dev/null
> which doesn't require an input file or run unnecessary passes of the compiler.
> (substitute NUL on windows)
Yes, that is better. Thanks. I tried to use it like this
(defun semantic-gcc-query (gcc-cmd &rest gcc-option)
"Query gcc. Return a list of configurations.
GCC-CMD is an optional command to execute instead of \"gcc\""
;; $ gcc -v
;;
(let ((buff (get-buffer-create " *gcc-query*")))
(save-excursion
(set-buffer buff)
(erase-buffer)
(condition-case nil
(apply 'call-process gcc-cmd nil buff nil gcc-option)
(error ;; Some bogus directory for the first time perhaps?
(let ((default-directory (expand-file-name "~/")))
(condition-case nil
(apply 'call-process gcc-cmd nil buff nil gcc-option)
(error ;; gcc doesn't exist???
nil)))))
(prog1
(buffer-string)
(kill-buffer buff)
))))
(defun semantic-gcc-get-include-paths (lang)
(let* ((gcc-cmd (cond
((string= lang "c") "gcc")
(t (error "Unknown lang: %s" lang))))
(gcc-output (semantic-gcc-query gcc-cmd "-v" "-E" "-x" lang)))
))
However calling (semantic-gcc-get-include-paths "c") does not catch
the output I want to gcc-output. I get
Result: "gcc.exe: warning: `-x c' after last input file has no
effect\nReading specs from
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs\nConfigured with:
../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld
--with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw
--enable-threads --disable-nls
--enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry
--disable-shared --enable-sjlj-exceptions --enable-libgcj
--disable-java-awt --without-x --enable-java-gc=boehm
--disable-libgcj-debug --enable-interpreter
--enable-hash-synchronization --enable-libstdcxx-debug\nThread model:
win32\ngcc version 3.4.5 (mingw-vista special r3)\n"
>> I believe this works on all os:es with gcc. It seems to include CPATH
>> and C_INCLUDE_PATH etc. However do not quite understand the output and
>> how to parse it. Could someone explain?
>
> This part of the output seems to have pretty well-defined markers, and
> lists the include directories one per line:
>
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/local/include
> /usr/lib/gcc/x86_64-linux-gnu/4.3.3/include
> /usr/lib/gcc/x86_64-linux-gnu/4.3.3/include-fixed
> /usr/include
> End of search list.
>
> Looks easy enough to parse (since there's a space prepended to each
> directory line, you don't even have to worry about a directory called
> "End of search list.", though an embedded newline might cause a
> mess... :).
Yes, but what about the two different categories of include paths. How
should they be handled? Just use both?
> Thanks,
>
> -Miles
>
> --
> Learning, n. The kind of ignorance distinguishing the studious.
>
>
>
>
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, (continued)
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Lennart Borgman, 2009/07/01
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Eli Zaretskii, 2009/07/01
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Eric M. Ludlam, 2009/07/01
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Lennart Borgman, 2009/07/02
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Eli Zaretskii, 2009/07/02
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Lennart Borgman, 2009/07/02
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Miles Bader, 2009/07/02
- Re: CEDET calls cpp -E -dM -x c++ /dev/null,
Lennart Borgman <=
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Eli Zaretskii, 2009/07/03
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Lennart Borgman, 2009/07/03
- Re: CEDET calls cpp -E -dM -x c++ /dev/null, Lennart Borgman, 2009/07/01