emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Naoya Yamashita <conao3@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Not working ob-C sample code
Date: Tue, 23 Jun 2020 09:54:52 +0900	[thread overview]
Message-ID: <CAEPcJak8wPr6NE6V9Q593TbDsZgnto=NHZ0VvwqokWru_mdKPQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2445 bytes --]

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<somedata_rows; i++) {
      printf ("%2d %7s ", i, somedata_h(i,"nb"));
      for (int j=1; j<somedata_cols; 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
‘<cstring>’; did you forget to ‘#include <cstring>’?
  +++ |+#include <cstring>
    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
‘<cstdio>’; did you forget to ‘#include <cstdio>’?
  +++ |+#include <cstdio>
    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,

[-- Attachment #2: Type: text/html, Size: 3104 bytes --]

             reply	other threads:[~2020-06-23  0:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  0:54 Naoya Yamashita [this message]
2020-06-23  2:11 ` ian martins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEPcJak8wPr6NE6V9Q593TbDsZgnto=NHZ0VvwqokWru_mdKPQ@mail.gmail.com' \
    --to=conao3@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Not working ob-C sample code' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).