[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Org Babel C/C++
From: |
Daimrod |
Subject: |
Re: [O] Org Babel C/C++ |
Date: |
Thu, 29 Mar 2012 01:01:07 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) |
Eric Schulte <address@hidden> writes:
> Applied, Thanks!
>
> Daimrod <address@hidden> 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.
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