all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to pass an array of integers to a C code block with :var?
@ 2016-08-09 18:32 Alef Farah
  0 siblings, 0 replies; only message in thread
From: Alef Farah @ 2016-08-09 18:32 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I am trying to use babel's :var to pass an array of integers to a C code
block. I can do it like this:

#+begin_src C :var arr='(1 2) :includes <stdio.h>
printf("%d %d\n", arr[0], arr[1]);
#+end_src

However, I wish to assign the output of another code block to the
variable, like this:

#+name: input
#+begin_src sh
seq 2
#+end_src

#+begin_src C :var arr=input :includes <stdio.h>
printf("%d %d\n", arr[0], arr[1]);
#+end_src

But this way, "arr" is evaluated as a string. I tried formatting the
output of the input code block as '(1 2), but it is still evaluated as a
string.

Is there any way to do this without manually grabbing the list from the
results of the input code block and pasting it in the C block?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-09 18:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-09 18:32 How to pass an array of integers to a C code block with :var? Alef Farah

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.