Hi, Bastien <b...@gnu.org> writes:
> Brandon Guttersohn <bran...@guttersohn.org> writes: > >> Hey all, I think I may have a small fix for executing C source blocks >> in org-babel. Or, possibly just a bad case of user error. >> >> The issue (in emacs 27 with -q) is that it doesn't seem possible to >> specify non-system header files with the :includes header argument. >> >> [...] >> >> The attached patch will wrap filenames in quotes if they do not begin >> with "<", and works for me. > > Thanks for reporting this and for suggesting this patch, I think it is > good enough. I have applied it to the master branch of Org: > > https://code.orgmode.org/bzg/org-mode/commit/44cb98fdb6 > > Best, I think this commit might have broken test ob-C/string-var: running "make test" on master (516c038e5) right now I get: > Test ob-C/string-var condition: > (wrong-type-argument sequencep <iostream>) > FAILED 8/834 ob-C/string-var (0.004651 sec) The following patch fixes the test:
diff --git a/lisp/ob-C.el b/lisp/ob-C.el index c3e72c680..ae7b2ed1c 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -233,6 +233,7 @@ its header arguments." ;; includes (mapconcat (lambda (inc) + (when (symbolp inc) (setq inc (symbol-name inc))) (if (string-prefix-p "<" inc) (format "#include %s" inc) (format "#include \"%s\"" inc)))
I don't know if it's the best way forward; another way to make the test pass is double-quoting "<iostream>" and "<cstring>" in ob-C-test.org:
diff --git a/testing/examples/ob-C-test.org b/testing/examples/ob-C-test.org index 0faf630b9..efae02a19 100644 --- a/testing/examples/ob-C-test.org +++ b/testing/examples/ob-C-test.org @@ -38,7 +38,7 @@ #+end_src #+source: string_var -#+begin_src cpp :var q="word" :includes '(<iostream> <cstring>) :results silent +#+begin_src cpp :var q="word" :includes '("<iostream>" "<cstring>") :results silent std::cout << q << ' ' << std::strlen(q); return 0; #+end_src
I guess there might be some people out there who will expect things to keep working without double-quotes? I have never used Babel, so I have no idea… I hope this has not already been brought up; apologies if so.