emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Roger Mason <rmason@mun.ca>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: C code block: no return values
Date: Tue, 16 Apr 2013 16:27:10 -0230	[thread overview]
Message-ID: <516D9F06.2030904@mun.ca> (raw)
In-Reply-To: <878v4ico1k.fsf@gmail.com>

Hello Eric,

On 04/16/2013 04:15 PM, Eric Schulte wrote:
> Roger Mason <rmason@mun.ca> writes:
>
>> Hello,
>>
>> I'm working through examples in "A Multi-Language Computing Environment for
>> Literate Programming and Reproducible Research" by Shulte et al. J.
>> Stat. Software, 46/3, 2012.
>>
>> This example compiles but results are not returned to the Org-mode buffer:
>>
>> Hi Roger,
>>
>> Since the publication of that paper, the code block execution engine has
>> begun checking the return value of the invoked program to ensure it
>> exits with success before parsing the output.  The C program in this
>> example actually returns the value of the final printf, which is
>> non-zero and looks like a return.
>>
>> To get this example working with the latest version of Org-mode, one
>> needs to added a "return 0;" to the end of the last code block, yielding
>> the following.
>>
>> #+name: main
>> #+begin_src C
>> int main(int argc, char *argv[]) {
>> int lst[argc-1];
>> int i;
>> for(i=1;i<argc;i++)
>> lst[i-1] = atoi(argv[i]);
>> sort(lst, argc-1);
>> for(i=1;i<argc;i++)
>> printf("%d ", lst[i-1]);
>> printf("\n");
>> return 0;
>> }
>> #+end_src
>>
>> With this change the example works as expected on my system.
>>
>> Org-mode should do a better job of alerting the user to the reason why
>> it is not returning a result.
>>
>> Cheers,
>>
Thank you.  It works here too.

Best wishes,
Roger


This electronic communication is governed by the terms and conditions at
http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php

      reply	other threads:[~2013-04-16 18:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 15:53 C code block: no return values Roger Mason
2013-04-16 18:45 ` Eric Schulte
2013-04-16 18:57   ` Roger Mason [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=516D9F06.2030904@mun.ca \
    --to=rmason@mun.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=schulte.eric@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).