From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Problems running C code in org-mode under Windows - SOLVED Date: Thu, 29 Mar 2012 15:18:23 -0400 Message-ID: <12168.1333048703@alphaville> References: <40C7B1BFC291ED4E9D10436D07736A334702EB9BB0@EXMAIL7.haas.uc.berkeley.edu> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:55486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDKrp-0005Xf-JL for emacs-orgmode@gnu.org; Thu, 29 Mar 2012 15:18:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDKrn-0001IF-Eo for emacs-orgmode@gnu.org; Thu, 29 Mar 2012 15:18:41 -0400 Received: from g1t0027.austin.hp.com ([15.216.28.34]:35813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDKrn-0001HV-7j for emacs-orgmode@gnu.org; Thu, 29 Mar 2012 15:18:39 -0400 In-Reply-To: Message from Richard Stanton of "Thu, 29 Mar 2012 10:41:16 PDT." <40C7B1BFC291ED4E9D10436D07736A334702EB9BB0@EXMAIL7.haas.uc.berkeley.edu> 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: Richard Stanton Cc: nicholas.dokos@hp.com, "'emacs-orgmode@gnu.org'" , 'Eric Schulte' Richard Stanton 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