emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Problems running C code in org-mode under Windows - SOLVED


From: Nick Dokos
Subject: Re: [O] Problems running C code in org-mode under Windows - SOLVED
Date: Thu, 29 Mar 2012 15:18:23 -0400

Richard Stanton <address@hidden> wrote:

> > To allow for people who might be using the Cygwin bash shell in Emacs
> > under Windows (which is recommended by many),  I do recommend making
> > the change I suggested above, adding the following lines to ob-C.el:
> > 
> > >          (tmp-bin-file (org-babel-temp-file
> > >                   "C-bin-"
> > >                   (if (equal system-type 'windows-nt) ".exe" "")))
> > >
> > 
> > This prevents bash trying to run an (empty) file with no extension when the
> > compiler has generated a file with a ".exe" extension. Otherwise, it looks
> > like I now have this running fine.
> > 
> > I also suggest not creating an empty binary file and just letting the 
> > compiler
> > create it, unless this poses some risks I'm not seeing.
> 
> One more quick follow-up: It seems that I need to add a "return(0);"
> line to my main routine to get any C examples to work under Windows,
> whereas I don't need to add such a line on my Mac. I just tried the
> cocktail.c example from your 2012 Journal of Statistical Software
> article, and this works on my Mac, but fails on my PC (even with my
> edits to ob-C.el) unless I add "return(0);" at the end of the main
> code block.
> 
> It would be nice for Windows users to be able to run others' examples
> without having to edit them first, so what do you think of the idea of
> having ob-C.el append a "return(0);" line to the main file before
> passing it to the compiler?
> 
> 

AFAIK, dropping off the end of main() without a return or call to exit()
is supposed to be equivalent to having a "return 0;" there. Assuming
that that is true, my $0.02 would be to leave it alone: there are too
many stupid bugs out there for org to fix. In this case, the compiler
(btw, which compiler is it?) should be fixed, not org. In addition,
there are not too many people that run this particular combination of
software (you are probably the only one), and now that you have found a
reasonable work-around for the problem, I'd encourage you to just add a
question-and-answer to the FAQ: imo, that's enough.

Nick




reply via email to

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