I have a program that I compile on two Ubuntu computers. Both are running 14.04 and presumably the same version of gcc. But when I compile it on one computer, I get the error
warning: format ‘%i’ expects argument of type ‘int’, but argument 4
has type ‘std::vector<colorgrad>::size_type {aka long unsigned int}’ [-Wformat=]
I think the offending code is
for (vector<colorgrad>::size_type i = 0; i < grad.size(); ++i) {
fprintf(svgOut, "%s%i%s%f%srgb(%i, %i, %i)%s\n", "<stop id=\"stop", i,"\" offset=\"",grad.at(i).perc ,"\" style=\"stop-color: ",grad.at(i).r, grad.at(i).g, grad.at(i).b, ";stop-opacity:1;\" />" );
}
The error goes away when I replace the first "%i" with a "%lu" but then when I compile that code on the other computer, gcc gives the opposite error and will only compile with a "%i".
How do I get this code to compile on both computers without having to switch out the "%i"'s every time I switch computers??