From mboxrd@z Thu Jan 1 00:00:00 1970 From: Amos Bird Subject: Re: evaluate cpp snippet in org babel with default includes and customized entry point Date: Sat, 16 Sep 2017 16:58:57 +0800 Message-ID: <874ls39fzi.fsf@gmail.com> References: <877ewz9j4x.fsf@gmail.com> <59BCE1F6.3060406@free.fr> <8760cj9gz2.fsf@gmail.com> <59BCE6DA.80907@free.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dt8wK-00025H-Fr for emacs-orgmode@gnu.org; Sat, 16 Sep 2017 04:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dt8wJ-0001oo-14 for emacs-orgmode@gnu.org; Sat, 16 Sep 2017 04:59:04 -0400 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]:49003) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dt8wI-0001oV-Pr for emacs-orgmode@gnu.org; Sat, 16 Sep 2017 04:59:02 -0400 Received: by mail-pf0-x232.google.com with SMTP id n24so2584754pfk.5 for ; Sat, 16 Sep 2017 01:59:02 -0700 (PDT) In-reply-to: <59BCE6DA.80907@free.fr> 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" To: Thierry Banel Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain #+OPTIONS: latex:t toc:nil H:3 Ok, i get the idea. So how can I customized the default code expansion so that it can directly evaluate this #+BEGIN_SRC cpp class Solution { public: vector twoSum(vector& nums, int target) { } }; #+END_SRC #+RESULTS: Thierry Banel writes: > You may use the :includes header parameter. > > Also, you may omit the main() function. In this case, all your code will become > the body of a default main function. Type C-c C-v v on the following example to > understand what is happening. > > > #+BEGIN_SRC C++ :includes > std::cout<<"hello"; > #+END_SRC > > #+RESULTS: > : hello > > > On 16/09/2017 10:37, Amos Bird wrote: >> >> Thanks Thierry, >> >> But I'd like to hide all those includes and the main function. I'm not sure if >> it's possible. >> >> -- Amos Bird amosbird@gmail.com --=-=-= Content-Type: multipart/related; boundary="==-=-=" --==-=-= Content-Type: text/html

Ok, i get the idea. So how can I customized the default code expansion so that it can directly evaluate this

class Solution {
public:
  vector<int> twoSum(vector<int>& nums, int target) {

  }
};

Thierry Banel <tbanelwebmin@free.fr> writes:

> You may use the :includes header parameter.
>
> Also, you may omit the main() function. In this case, all your code will become
> the body of a default main function. Type C-c C-v v on the following example to
> understand what is happening.
>
>
> #+BEGINSRC C++ :includes <iostream>
> std::cout<<"hello";
> #+ENDSRC
>
> #+RESULTS:
> : hello
>
>
> On 16/09/2017 10:37, Amos Bird wrote:
>>
>> Thanks Thierry,
>>
>> But I'd like to hide all those includes and the main function. I'm not sure if
>> it's possible.
>>
>>


Amos Bird
amosbird@gmail.com

--==-=-=-- --=-=-=--