emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] babel: ob-C with Visual C++ and compilation-mode


From: Ernesto Durante
Subject: Re: [O] babel: ob-C with Visual C++ and compilation-mode
Date: Wed, 20 Aug 2014 22:40:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux)

Thierry Banel <address@hidden> writes:

> You are trying to create a C++ project bigger than a few lines, in Org-mode.
> This is very close to the idea of "literate programming" from Donal Knuth.
> You may find inspiration here:
> http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming
>
> There is an example of a "hello world" shell project split over three source
> blocks.
> Here it is translated from Shell to C++ (try it, it works):
>
> #+name: hello-world-prefix
> #+begin_src C++ :exports none
> printf ("/-----------------------------------------------------------\\\n");
> #+end_src
>
> #+name: hello-world-postfix
> #+begin_src C++ :exports none
> printf ("\\-----------------------------------------------------------/\n");
> #+end_src
>
> #+name: hello-world-main-begin
> #+begin_src C++ :exports none
> #include <stdio.h>
> int main()
> {
> #+end_src
>
> #+name: hello-world-main-end
> #+begin_src C++ :exports none
> return 0;
> }
> #+end_src
>
> #+name: hello-world
> #+begin_src C++ :tangle hello :exports none :noweb yes :results output 
> <<hello-world-main-begin>>
> <<hello-world-prefix>>
> printf ("| hello world |\n");
> <<hello-world-postfix>>
> <<hello-world-main-end>>
> #+end_src
>
> #+RESULTS: hello-world
> : /-----------------------------------------------------------\
> : | hello world |
> : \-----------------------------------------------------------/

Really interesting. We can take some blocks and combine them inside
a source block. Thanks for this information.

Another question if you allow me ?
Looking at code in Ob-C you transform a table/list variable in a C array
of char*. Should it not be std::wstring ? some unicode string ?

Best Ernesto








reply via email to

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