On Wed, Jul 20, 2011 at 12:04 AM, Dirk Laurie
<dpl@sun.ac.za> wrote:
On Wed, Jul 20, 2011 at 04:06:58AM +0200, HyperHacker wrote:
>
> lua_tonumber returns a lua_Number, which is usually a double. You're
> then printing it with the %d format, which expects an integer.
> Compilers usually warn you about that kind of mismatch, but maybe
> yours didn't...
>
The GNU compiler, and probably many others, has a compiler flag that
turns warnings into errors. That makes it hard not to notice them.
$ gcc -Werror fmtbug.c
fmtbug.cc: In function ‘int main()’:
fmtbug.cc:6:19: error: format ‘%d’ expects type ‘int’, but argument 2 has type ‘double’
Dirk