From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id lekTC/Jk8V4ODgAA0tVLHw (envelope-from ) for ; Tue, 23 Jun 2020 02:12:02 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id uO7FBvJk8V5CXwAA1q6Kng (envelope-from ) for ; Tue, 23 Jun 2020 02:12:02 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7CA419402D6 for ; Tue, 23 Jun 2020 02:12:01 +0000 (UTC) Received: from localhost ([::1]:55036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnYPm-0002Hh-SV for larch@yhetil.org; Mon, 22 Jun 2020 22:11:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnYPL-0002G9-DU for emacs-orgmode@gnu.org; Mon, 22 Jun 2020 22:11:31 -0400 Received: from mail-ej1-f43.google.com ([209.85.218.43]:39226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jnYPI-00039c-AF for emacs-orgmode@gnu.org; Mon, 22 Jun 2020 22:11:31 -0400 Received: by mail-ej1-f43.google.com with SMTP id w6so8658649ejq.6 for ; Mon, 22 Jun 2020 19:11:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FNQz1804OYErvwKWnKOpaYhd9IFiRa5LknxvtGO1QBg=; b=pjPrzCB5+N9XfJtXJ9kskoqav8ZfaXHrxpYadmg7nuTLUmkvmcF7ddxtVsHDTlbyun 4dTM3cD+8205yHj3vNkoskegZccaohOUG2BJb6g4PN4g24wD3xc1GNjChqA1DKJqWrFT DVlk5nmSxa/FruKK5cLHywzYN8sXE1PujDn/iJLHf3P5telCXD2No73sbcb75ftP9z89 cmMwu8223DEyS+ejNLY+awkwjt9oGkABQSOUsBu810p7OBWoGPz0xQ/TrAIoJPPDreCa ne6FwyTjIIBNRATTeUMsxB7gn3J06IGOMmdOw2RV5tf9vCP5BzmIiBqgQh7GO+xmbneQ FCOQ== X-Gm-Message-State: AOAM530UY07VZuPY/NZv3LNKSgmQCP6Vo7Rubiobjnx9r88hvg1jbzNz 1RlVajrqt6CbdcmVD5wi8a4gDsSm43K6XUElXFs= X-Google-Smtp-Source: ABdhPJx32AmPpfQ0WSZW3K9F+t4UsUaDOFQwXZwvZ5+I2eLf+XzjnwT2eQJaQWiqOgH4GFDIaJMcVdj5xVLsHMtgHlo= X-Received: by 2002:a17:906:9147:: with SMTP id y7mr8274455ejw.399.1592878285894; Mon, 22 Jun 2020 19:11:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: ian martins Date: Mon, 22 Jun 2020 22:11:14 -0400 Message-ID: Subject: Re: Not working ob-C sample code To: Naoya Yamashita Content-Type: multipart/alternative; boundary="00000000000066b73605a8b6e09f" Received-SPF: pass client-ip=209.85.218.43; envelope-from=ianxm1@gmail.com; helo=mail-ej1-f43.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/22 22:11:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=jhu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: LmY4uu/kRJ/1 --00000000000066b73605a8b6e09f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Maybe you could use the C compiler instead of C++, or you could include the c libraries you need. try these options: ---- #+begin_src C :var somedata=3Dsomedata ---- #+begin_src C++ :var somedata=3Dsomedata :includes '( ) On Mon, Jun 22, 2020 at 8:56 PM Naoya Yamashita wrote: > Hi! I'm Naoya. This is the first mail to this ML. > > First, thank you for developing such awesome packages! > > I found ob-C sample[1] is not working for me, I report that to this ML. > > [1]: > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-C.org.html > > ## Repro step > 1. Require org and ob-C. > 2. Write below in some org buffer. > ```org > #+tblname: somedata > | nb | sqr | noise | > |-------+-----+-------| > | zero | 0 | 0.23 | > | one | 1 | 1.31 | > | two | 4 | 4.61 | > | three | 9 | 9.05 | > | four | 16 | 16.55 | > > #+name: c-table > #+header: :exports results > #+begin_src C++ :var somedata=3Dsomedata > int main() > { > for (int i=3D0; i printf ("%2d %7s ", i, somedata_h(i,"nb")); > for (int j=3D1; j const char* cell =3D somedata[i][j]; > printf ("%5s %5g ", cell, 1000*atof(cell)); > } > printf("\n"); > } > return 0; > } > #+end_src > ``` > 3. Babel src block via C-c C-c. > 4. Error occurred. I get below error output > ``` > /tmp/babel-kMPbac/C-src-KDQDdx.cpp: In function =E2=80=98int get_column_n= um(int, > const char**, const char*)=E2=80=99: > /tmp/babel-kMPbac/C-src-KDQDdx.cpp:17:9: error: =E2=80=98strcmp=E2=80=99 = was not declared > in this scope > 17 | if (strcmp(header[c],column)=3D=3D0) > | ^~~~~~ > /tmp/babel-kMPbac/C-src-KDQDdx.cpp:1:1: note: =E2=80=98strcmp=E2=80=99 is= defined in > header =E2=80=98=E2=80=99; did you forget to =E2=80=98#include <= cstring>=E2=80=99? > +++ |+#include > 1 | > /tmp/babel-kMPbac/C-src-KDQDdx.cpp: In function =E2=80=98int main()=E2=80= =99: > /tmp/babel-kMPbac/C-src-KDQDdx.cpp:27:5: error: =E2=80=98printf=E2=80=99 = was not declared > in this scope > 27 | printf ("%2d %7s ", i, somedata_h(i,"nb")); > | ^~~~~~ > /tmp/babel-kMPbac/C-src-KDQDdx.cpp:1:1: note: =E2=80=98printf=E2=80=99 is= defined in > header =E2=80=98=E2=80=99; did you forget to =E2=80=98#include =E2=80=99? > +++ |+#include > 1 | > /tmp/babel-kMPbac/C-src-KDQDdx.cpp:30:38: error: =E2=80=98atof=E2=80=99 w= as not declared > in this scope > 30 | printf ("%5s %5g ", cell, 1000*atof(cell)); > | ^~~~ > zsh:1: permission denied: /tmp/babel-kMPbac/C-bin-EfCzWt > ``` > > ## Some note > - These errors caused because a lack to include some library. > - Add some include statement generate and insert it in > `org-babel-C-utility-header-to-C`? > - Add new option for a user preamble and insert it in > `org-babel-C-expand-C`? > > Regards, > --00000000000066b73605a8b6e09f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Maybe you could use the C compiler instead of C++, or= you could include the c libraries you need. try these options:
----
#+begin_src C :var somedata=3Dsomedata
----
#+begin_src C++ :var somedata=3Dsomedata :includes '(<cstring= > <stdlib.h> <cstdio>)

On Mon, Jun 22, 2020 at 8:56= PM Naoya Yamashita <conao3@gmail.co= m> wrote:
Hi! I'm Naoya. This is the first mail to this ML.
First, thank you for developing=C2=A0such awesome packages!=

I found ob-C=C2=A0sample[1] is not working for me= , I report that to this ML.


## Repro step
1. Require o= rg and ob-C.
2. Write below in some org buffer.
```org<= /div>
#+tblname: somedata
| nb =C2=A0 =C2=A0| sqr | noise |
|----= ---+-----+-------|
| zero =C2=A0| =C2=A0 0 | =C2=A00.23 |
| one =C2= =A0 | =C2=A0 1 | =C2=A01.31 |
| two =C2=A0 | =C2=A0 4 | =C2=A04.61 |
= | three | =C2=A0 9 | =C2=A09.05 |
| four =C2=A0| =C2=A016 | 16.55 |
<= br>#+name: c-table
#+header: :exports results
#+begin_src C++ :var so= medata=3Dsomedata
=C2=A0 int main()
=C2=A0 {
=C2=A0 =C2=A0 for (in= t i=3D0; i<somedata_rows; i++) {
=C2=A0 =C2=A0 =C2=A0 printf ("%= 2d %7s ", i, somedata_h(i,"nb"));
=C2=A0 =C2=A0 =C2=A0 fo= r (int j=3D1; j<somedata_cols; j++) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 con= st char* cell =3D somedata[i][j];
=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf (&q= uot;%5s %5g ", cell, 1000*atof(cell));
=C2=A0 =C2=A0 =C2=A0 }
= =C2=A0 =C2=A0 =C2=A0 printf("\n");
=C2=A0 =C2=A0 }
=C2=A0 = =C2=A0 return 0;
=C2=A0 }
#+end_src
```
3. Ba= bel src block via C-c C-c.
4. Error occurred.=C2=A0 I get below e= rror output
```
/tmp/babel-kMPbac/C-src-KDQDdx.cpp: In = function =E2=80=98int get_column_num(int, const char**, const char*)=E2=80= =99:
/tmp/babel-kMPbac/C-src-KDQDdx.cpp:17:9: error: =E2=80=98strcmp=E2= =80=99 was not declared in this scope
=C2=A0 =C2=A017 | =C2=A0 =C2=A0 if= (strcmp(header[c],column)=3D=3D0)
=C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 = =C2=A0 =C2=A0 ^~~~~~
/tmp/babel-kMPbac/C-src-KDQDdx.cpp:1:1: note: =E2= =80=98strcmp=E2=80=99 is defined in header =E2=80=98<cstring>=E2=80= =99; did you forget to =E2=80=98#include <cstring>=E2=80=99?
=C2= =A0 +++ |+#include <cstring>
=C2=A0 =C2=A0 1 |
/tmp/babel-kMPb= ac/C-src-KDQDdx.cpp: In function =E2=80=98int main()=E2=80=99:
/tmp/babe= l-kMPbac/C-src-KDQDdx.cpp:27:5: error: =E2=80=98printf=E2=80=99 was not dec= lared in this scope
=C2=A0 =C2=A027 | =C2=A0 =C2=A0 printf ("%2d %7= s ", i, somedata_h(i,"nb"));
=C2=A0 =C2=A0 =C2=A0 | =C2= =A0 =C2=A0 ^~~~~~
/tmp/babel-kMPbac/C-src-KDQDdx.cpp:1:1: note: =E2=80= =98printf=E2=80=99 is defined in header =E2=80=98<cstdio>=E2=80=99; d= id you forget to =E2=80=98#include <cstdio>=E2=80=99?
=C2=A0 +++ |= +#include <cstdio>
=C2=A0 =C2=A0 1 |
/tmp/babel-kMPbac/C-src-K= DQDdx.cpp:30:38: error: =E2=80=98atof=E2=80=99 was not declared in this sco= pe
=C2=A0 =C2=A030 | =C2=A0 =C2=A0 =C2=A0 printf ("%5s %5g ", = cell, 1000*atof(cell));
=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^~~~
zsh:1: permission denied: /tmp/ba= bel-kMPbac/C-bin-EfCzWt
```

## Some = note
- These errors caused because a lack to include=C2=A0some li= brary.
=C2=A0 - Add some include statement generate and insert it= in `org-babel-C-utility-header-to-C`?
=C2=A0 - Add new option fo= r a user preamble and insert it in `org-babel-C-expand-C`?

Regards,
--00000000000066b73605a8b6e09f--