From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: babel: ob-C with Visual C++ and compilation-mode Date: Mon, 18 Aug 2014 21:59:27 +0200 Message-ID: <53F25B1F.3020804@free.fr> References: <878un4ut6c.fsf@gmail.com> <53E91C32.4000002@free.fr> <87lhqt6b0w.fsf@gmail.com> <53EA8F2B.7010205@free.fr> <87zjf8cdjk.fsf@gmail.com> <53ED1EB0.3030500@free.fr> <87lhqp7jnp.fsf@gmail.com> <53F08FE3.20506@free.fr> <87vbpq6o4w.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJT5Z-0001hz-SC for emacs-orgmode@gnu.org; Mon, 18 Aug 2014 15:59:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJT5V-0002jn-Mj for emacs-orgmode@gnu.org; Mon, 18 Aug 2014 15:59:33 -0400 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]:22806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJT5V-0002jg-CK for emacs-orgmode@gnu.org; Mon, 18 Aug 2014 15:59:29 -0400 Received: from [IPv6:2a01:e35:2e21:def0:b41a:8974:3413:c7bf] (unknown [IPv6:2a01:e35:2e21:def0:b41a:8974:3413:c7bf]) by smtp1-g21.free.fr (Postfix) with ESMTP id BABF194012C for ; Mon, 18 Aug 2014 21:59:27 +0200 (CEST) In-Reply-To: <87vbpq6o4w.fsf@gmail.com> 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: emacs-orgmode@gnu.org
Le 18/08/2014 13:19, Ernesto Durante a =C3=A9crit=C2=A0:
I think the problem we are trying to integrate C++/C=
 like
Lisp,Python,Haskell or programming languages which can rely on a session
to share their content. In a way, the idea of Babel originated from such
a session oriented languages.=20

C++ is very different. We cannot inject codes through a online session.
It's really a non sense. C++ is constructed around the idea of a project
(or a Makefile). A typical C++ project holds header files + source files =
+
a main file.

As you have pointed out, the current C++ mode, is very specialized for
dealing with a main file. It's right name should be something
like :mainC++ .

So how to deal with a C++ project ?=20

I enjoy programming in Qt and I have been trying to integrate into Babel,=
 a Qmake
project. I finally end up by creating three specialized C++ mode:
qheader, qsource and qmain. It was frustating because I couldn't reuse th=
e
standard C++ mode and in some way the core API in ob-C.

It's my personal conclusion that orgmode gives a new light on C++/Qmake
project by making it more accessible more easy to grasp.

Does it make sense to you ?

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
=C2=A0 printf ("/-----------------------------------------------------------\\\n"= );
#+end_src

#+name: hello-world-postfix
#+begin_src C++ :exports none
=C2=A0 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
=C2=A0 return 0;
}
#+end_src

#+name: hello-world
#+begin_src C++ :tangle hello :exports none :noweb yes :results output
=C2=A0 <<hello-world-main-begin>>
=C2=A0 <<hello-world-prefix>>
=C2=A0 printf ("|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 hello world=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 |\n");
=C2=A0 <<hello-world-postfix>>
=C2=A0 <<hello-world-main-end>>
#+end_src

#+RESULTS: hello-world
: /-----------------------------------------------------------\
: |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hello = world=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= |
: \-----------------------------------------------------------/