org babel tangle file without main function
Asked Answered
L

1

7

I am using the fantastic org-babel package for emacs.

I want to generate some code WITHOUT the main function in it for C++ code, but I cannot figure out how to do it.

#+begin_src C++ :tangle MyClass.h
namespace ns {
    class MyClass {};
}
#+end_src

This will generate:

int main() {
    namespace ns {
       class MyClass {};
    }
}

Is there a way I can instruct org-babel to not generate a main function? I could not find any documentation or hint anywhere.

Any alternative that lets me inline the code in the org file and tangle it without evaluation would be a solution too for my current problem.

Leatherworker answered 26/9, 2014 at 21:17 Comment(0)
L
12

So I found how to do it in the documentation, finally:

:main can be set to "no" to inhibit wrapping of the code block in a main function call.

#+begin_src C++ :main no
//Code goes here
#+end_src

This will do it.

Leatherworker answered 26/9, 2014 at 22:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.