lua-users home
lua-l archive

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


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