* org-babel-C-ensure-main-wrap fails unless I add exit(0)
@ 2012-04-04 8:13 Dov Grobgeld
2012-04-05 5:25 ` Dov Grobgeld
0 siblings, 1 reply; 5+ messages in thread
From: Dov Grobgeld @ 2012-04-04 8:13 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 435 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 536 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel-C-ensure-main-wrap fails unless I add exit(0)
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
0 siblings, 1 reply; 5+ messages in thread
From: Dov Grobgeld @ 2012-04-05 5:25 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 634 bytes --]
Oops. I sawthat I wrote "do not get any error" though I meant "do not get
any resulting output".
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
>
>
[-- Attachment #2: Type: text/html, Size: 1037 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel-C-ensure-main-wrap fails unless I add exit(0)
2012-04-05 5:25 ` Dov Grobgeld
@ 2012-04-05 14:56 ` Eric Schulte
2012-04-05 18:07 ` Dov Grobgeld
0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2012-04-05 14:56 UTC (permalink / raw)
To: Dov Grobgeld; +Cc: emacs-orgmode
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel-C-ensure-main-wrap fails unless I add exit(0)
2012-04-05 14:56 ` Eric Schulte
@ 2012-04-05 18:07 ` Dov Grobgeld
2012-04-11 1:41 ` Eric Schulte
0 siblings, 1 reply; 5+ messages in thread
From: Dov Grobgeld @ 2012-04-05 18:07 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]
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 <eric.schulte@gmx.com> wrote:
> 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/
>
[-- Attachment #2: Type: text/html, Size: 2340 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel-C-ensure-main-wrap fails unless I add exit(0)
2012-04-05 18:07 ` Dov Grobgeld
@ 2012-04-11 1:41 ` Eric Schulte
0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2012-04-11 1:41 UTC (permalink / raw)
To: Dov Grobgeld; +Cc: emacs-orgmode
Applied, thanks!
Dov Grobgeld <dov.grobgeld@gmail.com> 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 <eric.schulte@gmx.com> wrote:
>
>> 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/
>>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-04-11 3:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2012-04-05 18:07 ` Dov Grobgeld
2012-04-11 1:41 ` Eric Schulte
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).