emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org-babel-C-ensure-main-wrap fails unless I add exit(0)


From: Eric Schulte
Subject: Re: [O] org-babel-C-ensure-main-wrap fails unless I add exit(0)
Date: Tue, 10 Apr 2012 21:41:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Applied, thanks!

Dov Grobgeld <address@hidden> writes:

> Sure. They should be equivalent. (In C++ return is prefered as it calls
> destructors. But anyone relying on this when using C++ in org-mode should
> imnsho get a permanent ban from ever using C/C++ ;-).
>
> Regards,
> Dov
>
> On Thu, Apr 5, 2012 at 17:56, Eric Schulte <address@hidden> wrote:
>
>> Dov Grobgeld <address@hidden> 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 <address@hidden>
>> 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/
>>

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]