while (ii<(filesize-6)) ambiguous - how to fix

I have two variables, named ii and filesize,
both are of type ifstream::pos_type

filesize holds the size of a file to be iterated through,
and I have a simple do - while loop to do it.

But instead of running to the very end, I'd like it to stop
6 steps before hitting the file end. So, dumb as I am, I just have like:

1
2
3
4
5
6
7
  ii=0;
  do
  {
   // it actually does something here
   ii+=1;
  }
  while (ii<(filesize-6));


but that "while (ii<filesize-6)" makes g++ to say:

warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
/usr/include/c++/4.4/bits/postypes.h:192: note: candidate 1: std::fpos<_StateT> std::fpos<_StateT>::operator-(std::streamoff) const [with _StateT = __mbstate_t]
browser.cpp:60: note: candidate 2: operator-(std::streamoff, int) <built-in>


Well, I think that the workaround is to have
 
  filesize-=6

before the do - while -loop

but still, I'd like to ask if there is an another way - as I'd like to keep the original value in filesize, because I need it later on in the code.

I hope this makes some sense.
Last edited on
try this: while (ii<(((int)filesize)-6))
before posting my question I already tried while (ii<int (filesize-6));
but it still gave the same warning.

So, it turns out that I had my typecasting wrong, as while (ii<((int)filesize-6)); works fine.

Thank you very much, viliml!

Topic archived. No new replies allowed.