emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Richard Stanton <stanton@haas.berkeley.edu>
Cc: nicholas.dokos@hp.com,
	"'emacs-orgmode@gnu.org'" <emacs-orgmode@gnu.org>,
	'Eric Schulte' <eric.schulte@gmx.com>
Subject: Re: Problems running C code in org-mode under Windows - SOLVED
Date: Thu, 29 Mar 2012 15:18:23 -0400	[thread overview]
Message-ID: <12168.1333048703@alphaville> (raw)
In-Reply-To: Message from Richard Stanton <stanton@haas.berkeley.edu> of "Thu, 29 Mar 2012 10:41:16 PDT." <40C7B1BFC291ED4E9D10436D07736A334702EB9BB0@EXMAIL7.haas.uc.berkeley.edu>

Richard Stanton <stanton@haas.berkeley.edu> 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	other threads:[~2012-03-29 19:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-29 17:41 Problems running C code in org-mode under Windows - SOLVED Richard Stanton
2012-03-29 19:18 ` Nick Dokos [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-03-29 17:29 Richard Stanton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12168.1333048703@alphaville \
    --to=nicholas.dokos@hp.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric.schulte@gmx.com \
    --cc=stanton@haas.berkeley.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).