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=somedata
#+begin_src C++ :var somedata=somedata :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=somedata
> int main()
> {
> for (int i=0; i printf ("%2d %7s ", i, somedata_h(i,"nb"));
> for (int j=1; j const char* cell = 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 ‘int get_column_num(int,
> const char**, const char*)’:
> /tmp/babel-kMPbac/C-src-KDQDdx.cpp:17:9: error: ‘strcmp’ was not declared
> in this scope
>17 | if (strcmp(header[c],column)==0)
> | ^~
> /tmp/babel-kMPbac/C-src-KDQDdx.cpp:1:1: note: ‘strcmp’ is defined in
> header ‘’; did you forget to ‘#include ’?
> +++ |+#include
> 1 |
> /tmp/babel-kMPbac/C-src-KDQDdx.cpp: In function ‘int main()’:
> /tmp/babel-kMPbac/C-src-KDQDdx.cpp:27:5: error: ‘printf’ 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: ‘printf’ is defined in
> header ‘’; did you forget to ‘#include ’?
> +++ |+#include
> 1 |
> /tmp/babel-kMPbac/C-src-KDQDdx.cpp:30:38: error: ‘atof’ was 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,
>