[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Issues with lua_tonumber
- From: Dirk Laurie <dpl@...>
- Date: Wed, 20 Jul 2011 06:04:16 +0200
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