From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: org-babel-C-ensure-main-wrap fails unless I add exit(0) Date: Thu, 05 Apr 2012 10:56:18 -0400 Message-ID: <87lima8bxp.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:37278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFpzG-0000d2-7U for emacs-orgmode@gnu.org; Thu, 05 Apr 2012 12:56:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFpzC-0008LO-Fs for emacs-orgmode@gnu.org; Thu, 05 Apr 2012 12:56:41 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:42931) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SFpzC-0008L9-93 for emacs-orgmode@gnu.org; Thu, 05 Apr 2012 12:56:38 -0400 In-Reply-To: (Dov Grobgeld's message of "Thu, 5 Apr 2012 08:25:16 +0300") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dov Grobgeld Cc: emacs-orgmode Dov Grobgeld 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 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 ` 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/