emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Dov Grobgeld <dov.grobgeld@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: org-babel-C-ensure-main-wrap fails unless I add exit(0)
Date: Thu, 05 Apr 2012 10:56:18 -0400	[thread overview]
Message-ID: <87lima8bxp.fsf@gmx.com> (raw)
In-Reply-To: <CA++fsGExH_452iJ=UOeMQxCzha-sUGOJy4OKt5uwoV1DYFv43Q@mail.gmail.com> (Dov Grobgeld's message of "Thu, 5 Apr 2012 08:25:16 +0300")

Dov Grobgeld <dov.grobgeld@gmail.com> writes:

> Oops. I sawthat  I wrote "do not get any error" though I meant "do not get
> any resulting output".
>

Would this alternate version work (without requiring stdlib.h)?

(defun org-babel-C-ensure-main-wrap (body)
  "Wrap body in a \"main\" function call if none exists."
  (if (string-match "^[ \t]*[intvod]+[ \t\n\r]*main[ \t]*(.*)" body)
      body
    (format "int main() {\n%s\nreturn(0);\n}\n" body)))

Thanks,

>
> On Wed, Apr 4, 2012 at 11:13, Dov Grobgeld <dov.grobgeld@gmail.com> wrote:
>
>> When running a babel C session under Linux/gcc I do not get any error
>> unless I add exit(0) as part of the C-code snippet. For some to me not
>> understood reason my program exits with error code=4, which is caught by
>> org-babel-eval and the printed output is not inserted into my buffer . I
>> solved this by adding `#include <stdlib.h>` and `exit(0);` as part of
>> org-babel-C-ensure-main-wrap .
>>
>> Should I prepare this as patch?
>>
>> Regards,
>> Dov
>>
>>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

  reply	other threads:[~2012-04-05 16:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-04  8:13 org-babel-C-ensure-main-wrap fails unless I add exit(0) Dov Grobgeld
2012-04-05  5:25 ` Dov Grobgeld
2012-04-05 14:56   ` Eric Schulte [this message]
2012-04-05 18:07     ` Dov Grobgeld
2012-04-11  1:41       ` Eric Schulte

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=87lima8bxp.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=dov.grobgeld@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).