From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: CEDET calls cpp -E -dM -x c++ /dev/null Date: Fri, 3 Jul 2009 13:22:44 +0200 Message-ID: References: <83tz1v3gz3.fsf@gnu.org> <1246505665.21630.7.camel@projectile.siege-engine.com> <83ocs23muc.fsf@gnu.org> <87ocs2vbja.fsf@catnip.gol.com> <83my7m2jly.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1246620187 24162 80.91.229.12 (3 Jul 2009 11:23:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Jul 2009 11:23:07 +0000 (UTC) Cc: eric@siege-engine.com, emacs-devel@gnu.org, miles@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 03 13:23:00 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MMgr5-00058g-PN for ged-emacs-devel@m.gmane.org; Fri, 03 Jul 2009 13:23:00 +0200 Original-Received: from localhost ([127.0.0.1]:52594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMgr4-0007BO-UY for ged-emacs-devel@m.gmane.org; Fri, 03 Jul 2009 07:22:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MMgqz-0007Aw-Sv for emacs-devel@gnu.org; Fri, 03 Jul 2009 07:22:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MMgqv-0007AW-QW for emacs-devel@gnu.org; Fri, 03 Jul 2009 07:22:53 -0400 Original-Received: from [199.232.76.173] (port=52276 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMgqv-0007AT-Li for emacs-devel@gnu.org; Fri, 03 Jul 2009 07:22:49 -0400 Original-Received: from mail-bw0-f210.google.com ([209.85.218.210]:48038) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MMgqr-00062v-Vl; Fri, 03 Jul 2009 07:22:46 -0400 Original-Received: by bwz6 with SMTP id 6so967895bwz.42 for ; Fri, 03 Jul 2009 04:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=1X31YscEspJ6QUpENkQuZa0RtYr2yZ537rPe0YESRx4=; b=bpykZCE32jCp22VAugjS5uEQUfv1EYfn/I1FNEEXBp3PsLfAcGK01bDlqXlObRQvaI oRsHDSYKUWaWNQ8LcENRDEiQSnSLKZFrb/5BVfoZWSyOMIufnR1HpNUQ6dz3PnQ0tGmf I8b+Df9IZSveD27QpBNk220E8FU3blpmgEktw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=YtXakLxpn4vVYfeLErUDE7v57eboEvcvZU0tv2tp1FVoSrJXsF2f1aAWfy/jxUfKxr Q/Ig4pzKB+1JM/lFdqITgNGEl5NZebnWjhRKia9tPw8yE9iOIncYbgmAsNg1LUmCsEO+ yRdw91qnSpDpWFjLUrSTuPGol+njVjfvjFQ1Y= Original-Received: by 10.239.133.69 with SMTP id 5mr94790hbu.4.1246620164690; Fri, 03 Jul 2009 04:22:44 -0700 (PDT) In-Reply-To: <83my7m2jly.fsf@gnu.org> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:111949 Archived-At: On Fri, Jul 3, 2009 at 11:36 AM, Eli Zaretskii wrote: >> Date: Fri, 3 Jul 2009 03:13:12 +0200 >> From: Lennart Borgman >> Cc: "Eric M. Ludlam" , >> =C2=A0 =C2=A0 =C2=A0 Emacs-Devel devel >> >> (defun semantic-gcc-get-include-paths (lang) >> =C2=A0 (let* ((gcc-cmd (cond >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((s= tring=3D lang "c") "gcc") >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(t = (error "Unknown lang: %s" lang)))) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(gcc-output (semantic-gcc-query gcc-cm= d "-v" "-E" "-x" lang))) >> =C2=A0 =C2=A0 )) >> >> 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\n > > This is because your forgot to append null-device to the arguments you > pass to semantic-gcc-get-include-paths. =C2=A0So the command line ends wi= th > a "-x c", which, as GCC tells you, is quite pointless without a file > name after it. Thanks. >> Yes, but what about the two different categories of include paths. How >> =C2=A0should they be handled? Just use both? > > Yes, both. > > Btw, as Miles's output shows, there could be more than 2 directories > in this list, and all of them should be looked in. =C2=A0AFAIR, the order > of lookup should be the order in which GCC prints them, because that's > what GCC does. What about this version? (defun semantic-gcc-query (gcc-cmd &rest gcc-option) "Return command output. GCC-CMD is the command to execute and GCC-OPTIONS are the options to give to the command." ;; $ 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 (cons buff t) 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 (cons buff t) nil gcc-optio= n) (error ;; gcc doesn't exist??? nil))))) (prog1 (buffer-string) (kill-buffer buff) )))) ;;(semantic-gcc-get-include-paths "c") ;;(semantic-gcc-get-include-paths "c++") (defun semantic-gcc-get-include-paths (lang) (let* ((gcc-cmd (cond ((string=3D lang "c") "gcc") ((string=3D lang "c++") "c++") (t (error "Unknown lang: %s" lang)))) (gcc-output (semantic-gcc-query gcc-cmd "-v" "-E" "-x" lang null-device)) (lines (split-string gcc-output "\n")) (include-marks 0) (inc-mark "#include ") (inc-mark-len (length "#include ")) inc-path) (message "gcc-output=3D%s" gcc-output) (dolist (line lines) (when (> (length line) 1) (if (=3D 0 include-marks) (when (and (> (length line) inc-mark-len) (string=3D inc-mark (substring line 0 inc-mark-len))= ) (setq include-marks (1+ include-marks))) (let ((chars (append line nil))) (when (=3D 32 (nth 0 chars)) (when (if (memq system-type '(windows-nt)) (/=3D ?/ (nth 1 chars)) (=3D ?/ (nth 1 chars))) (add-to-list 'inc-path (expand-file-name (substring line 1)) t))))))) inc-path))