lua-users home
lua-l archive

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


2007/3/25, Chris <coderight@gmail.com>:
Another compiler warning except this time for Microsoft Visual Studio 2003:

src\print.c(26) : warning C4267: 'initializing' : conversion from
'size_t' to 'int', possible loss of data

Effectively sizeof(int)<sizeof(size_t) on most 64bits platforms, so
the following patch removes the warning and make the code safer in the
improbable eventuality that ts->tsv.len is bigger than 2 trillions:

diff -u a/print.c b/print.c
--- a/print.c	Fri Mar 23 13:08:42 2007
+++ b/print.c	Sun Mar 25 19:21:54 2007
@@ -23,8 +23,8 @@
static void PrintString(const TString* ts)
{
 const char* s=getstr(ts);
- int n=ts->tsv.len;
- int i;
+ size_t n=ts->tsv.len;
+ size_t i;
 putchar('"');
 for (i=0; i<n; i++)
 {