lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Good catch.

Turns out the Makefile I was using (written by someone else) was setting -Wno-format, which turned off that warning. That's why I didn't see it in the first place.

Thanks,

Eddie Ringle

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