From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: URGENT Org Babel C/C++ Date: Sat, 31 Mar 2012 11:47:52 -0400 Message-ID: <87vclkojpz.fsf_-_@gmx.com> References: <87fwcz6vbf.fsf@gmail.com> <87wr67po1v.fsf@gmx.com> <87zkb0qqj0.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:34158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SE2PK-0006P1-Pj for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 13:48:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SE2PI-0007hb-Pq for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 13:48:10 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:55985) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SE2PI-0007hM-JS for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 13:48:08 -0400 In-Reply-To: <87zkb0qqj0.fsf@gmail.com> (daimrod@gmail.com's message of "Thu, 29 Mar 2012 01:01:07 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Daimrod Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Daimrod writes: > Eric Schulte writes: > >> Applied, Thanks! >> >> Daimrod writes: >> >>> Hi, >>> >>> I've made a small patch to ob-C.el so it now includes the current >>> directory to the list of directories to be searched for header files. >>> Without this, I cannot include a local header file because the >>> compilation happens in /tmp and thus gcc or g++ doesn't search for >>> header files in the directory I currently work. >>> >>> diff --git a/lisp/ob-C.el b/lisp/ob-C.el >>> index f1525aa..4f33fc4 100644 >>> --- a/lisp/ob-C.el >>> +++ b/lisp/ob-C.el >>> @@ -96,15 +96,14 @@ or `org-babel-execute:C++'." >>> (progn >>> (with-temp-file tmp-src-file (insert full-body)) >>> (org-babel-eval >>> - (format "%s -o %s %s %s -I \"%s\"" >>> + (format "%s -o %s %s %s" >>> (cond >>> ((equal org-babel-c-variant 'c) org-babel-C-compiler) >>> ((equal org-babel-c-variant 'cpp) org-babel-C++-compiler)) >>> (org-babel-process-file-name tmp-bin-file) >>> (mapconcat 'identity >>> (if (listp flags) flags (list flags)) " ") >>> - (org-babel-process-file-name tmp-src-file) >>> - (file-name-directory (expand-file-name (buffer-file-name)))) "")))) >>> + (org-babel-process-file-name tmp-src-file)) "")))) >>> ((lambda (results) >>> (org-babel-reassemble-table >>> (if (member "vector" (cdr (assoc :result-params params))) > > Hum, I'm quite embarrassed, this doesn't work when the block is executed > during an export. I didn't track it down yet, but (buffer-file-name) > returns nil during the export probably because the buffer changes. > I've reverted this commit, I should have been more cautious in its application. I've reverted this commit in both the hotfix-7.8.06 branch and the master branch. > > A workaround would be to use the :flags header argument though it's a > bit tedious because it doesn't seem possible to eval elisp during the > export. > > i.e. > > #+BEGIN_SRC cpp :flags -I (file-name-directory (buffer-file-name)) > ... > #+END_SRC I don't believe the above statement is true, for example the following code block evaluates its header argument on export. --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=example.org Example of code eval during export. #+headers: :exports results #+begin_src emacs-lisp :var this=(file-name-directory (buffer-file-name)) this #+end_src --=-=-= Content-Type: text/plain Best, -- Eric Schulte http://cs.unm.edu/~eschulte/ --=-=-=--