3

Please consider the following self-contained, minimal example org file:

#+name: zepto-c
#+CAPTION: A tiny C file
#+begin_src C++ :tangle zepto.c
#include "zepto.h"
void foo (void) {}
#+end_src

#+name: zepto-h
#+CAPTION: A tiny header file
#+begin_src C++ :tangle zepto.h
#include <stdio.h>
void foo (void);
#+end_src

On org-babel-tangle, it produces the expected two files, zepto.c and zepto.h, but they contain wrappers with main:

zepto.c:

int main() {
#include "zepto.h"
void foo (void) {}
return 0;
}

zepto.h:

int main() {
#include <stdio.h>
void foo (void);
return 0;
}

I just want org-babel to tangle out exactly what I wrote, with no modifications. I have tried many combinations of headers :eval, :results, :exports, :tangle, and :noweb from the documentation, even trying verbatim values for them in the hopes that some undocumented feature will give me the results I want, but no luck. The space of all possibile values for those headers is combinatorially large, so it could take me a long time to try them all. Perhaps someone knows the correct incantation?

I will be grateful for any advice.

  • Have you tried :main no? – mutbuerger Jun 11 '17 at 19:29
  • Well that was easy :-/ I completely missed it in the documentation. Feel free to hoist it to an answer and I'll accept it. – Reb.Cabin Jun 11 '17 at 20:14
4

There is a :main header argument defined in ob-C. :main no avoids the wrapping.

  • Thanks for the answer. I also had the problem recently in September 2017. I wish that the default value of :main should be no Do you know how to do that? – Yu Shen Sep 22 '17 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.