From: Thierry Banel <tbanelwebmin@free.fr>
To: emacs-orgmode@gnu.org
Subject: Re: babel C, C++, D enhancement
Date: Sat, 14 Jun 2014 00:07:43 +0200 [thread overview]
Message-ID: <539B762F.90406@free.fr> (raw)
In-Reply-To: <87ha3p8fq9.fsf@Rainer.invalid>
Thanks Achim for finding and fixing this bug.
I do agree about fuzziness between int and float.
My Emacs considers
2305843009213693951 as an integer,
2305843009213693952 too large to be an integer.
My C++ compiler sees
4294967295 as an integer,
4294967296 as too large to fit an int.
So Babel C++ may cause problem for large integers.
I am not sure how we can fix this in any case.
In the meantime, we can force large values to be declared as doubles by
adding dot zero
like this:
#+BEGIN_SRC C++ :var large=9876543210 .0
printf ("%g", large);
#+END_SRC
Thierry
Le 13/06/2014 08:51, Achim Gratz a écrit :
> Eric Schulte writes:
>> This new patch looks great, and the test suite passes locally. I've
>> just applied it.
> You also get a warning from the byte-compiler on something that is
> clearly a bug. I think the fix should be:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/ob-C.el b/lisp/ob-C.el
> index dd03fa7..a794e2a 100644
> --- a/lisp/ob-C.el
> +++ b/lisp/ob-C.el
> @@ -264,7 +264,7 @@ (defun org-babel-C-val-to-C-type (val)
> (list
> (if (equal org-babel-c-variant 'd) "string" "const char*")
> "\"%s\""))
> - (t (error "unknown type %S" type)))))
> + (t (error "unknown type %S" basetype)))))
> (cond
> ((integerp val) type) ;; an integer declared in the #+begin_src line
> ((floatp val) type) ;; a numeric declared in the #+begin_src line
> --8<---------------cut here---------------end--------------->8---
>
> The type determination is a tad optimistic, too. An Emacs integer may
> or may not fit into C type "int" depending on how Emacs is compiled and
> which compiler you are using.
>
>
> Regards,
> Achim.
next prev parent reply other threads:[~2014-06-13 22:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-11 1:34 Patch for testing `org-open-at-point' York Zhao
2014-04-11 7:23 ` Nicolas Goaziou
2014-04-11 10:25 ` Bastien
2014-04-12 14:22 ` York Zhao
2014-04-17 18:48 ` Bastien
2014-04-20 19:19 ` Michael Strey
2014-04-20 19:56 ` York Zhao
2014-06-01 1:12 ` York Zhao
2014-06-01 8:53 ` Bastien
2014-06-01 20:15 ` Achim Gratz
2014-06-01 21:14 ` Bastien
2014-06-01 21:58 ` babel C, C++, D enhancement Thierry Banel
2014-06-06 16:31 ` Eric Schulte
2014-06-07 18:19 ` Thierry Banel
2014-06-08 20:19 ` Thierry Banel
2014-06-08 23:22 ` Eric Schulte
2014-06-09 9:40 ` Thierry Banel
2014-06-13 6:51 ` Achim Gratz
2014-06-13 11:47 ` Eric Schulte
2014-06-13 22:07 ` Thierry Banel [this message]
2014-06-16 18:28 ` Achim Gratz
2014-06-16 20:49 ` Thierry Banel
2014-06-16 21:14 ` Thomas S. Dye
2014-06-16 22:24 ` Nick Dokos
2014-06-17 17:16 ` Achim Gratz
2014-06-17 20:51 ` Thierry Banel
2014-06-13 10:55 ` Bastien
2014-06-13 11:58 ` conforming commit messages Was: " Eric Schulte
2014-06-13 14:50 ` Eric Abrahamsen
2014-06-02 19:13 ` Patch for testing `org-open-at-point' Achim Gratz
2014-06-03 7:22 ` Bastien
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=539B762F.90406@free.fr \
--to=tbanelwebmin@free.fr \
--cc=emacs-orgmode@gnu.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public 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).