Re: gcc C++ app: need a double, but gcc converts back to long

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

 



problem to solve: the app fails on all files larger than 4.2GB. The

4.2GB is around 2^32B.  ie, you probably have an overflow problem

Line 191 of utils.cpp:
unsigned long fileSize = FileSize(fileName);

i am assuming here that FileSize returns an unsigned long?

Simple enough. But when I change it to be a double,

double fileSize = FileSize(fileName);

gcc gives the following warning:

utils/utils.cpp:191: warning: converting to 'long unsigned int' from 'double'

are you sure this is the error message?  fileName is probably not a
double, so i can't see where the conversion _from_ a double occurs.

Why does GCC do this conversion? How can I keep fileSize long?

you want FileSize to return an  unsigned long long  (a 64 bit value),
so declare fileSize as an unsigned long long.

however, i get the impression that FileSize only returns a 32 bit
value, so you need to  change this.  post the source for FileSize and
i'll see if i can help.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux