#2 Warning: printf %d of size_t

open
nobody
None
5
2011-10-19
2011-10-19
Clem Wang
No

This warning should be fixed to make the code more portable:

dataset.cpp: In static member function ‘static int dataset::write_wordmap(std::string, mapword2id*)’:
dataset.cpp:40: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’

Line 40:

fprintf(fout, "%d\n", pword2id->size());

should be:

fprintf(fout, "%zu\n", pword2id->size());

Discussion