W
William Payne
Hello! I realise questions about compilers are considered off-topic here but
I still would like to know if the following statement is considered safe. My
compiler warns about it (see below).
the statement:
long size = type == TYPE_FOLDER ? -1 : find_data.nFileSizeLow / 1024;
the warning:
main_window_procedure.cpp:129: warning: converting of negative value
`-0x0000000
01' to `long unsigned int'
type is an instance of:
enum Type
{
TYPE_FILE,
TYPE_FOLDER
};
find_data.nFileSizeLow is of type unsigned long
I am using GCC 3.4.0.
I don't understand that warning at all...the only problem I can see is if
the result of find_data.nFileSizeLow / 1024 is too big to fit in a long, but
the warning doesn't seem to be about that, or? (As a side note, I am not too
worried that the long will overflow in real-world use). I always like to
compile my code with warning level cranked up to max then I try to get rid
of most of warnings or at least understand them.
Thanks for any replies
/ WP
I still would like to know if the following statement is considered safe. My
compiler warns about it (see below).
the statement:
long size = type == TYPE_FOLDER ? -1 : find_data.nFileSizeLow / 1024;
the warning:
main_window_procedure.cpp:129: warning: converting of negative value
`-0x0000000
01' to `long unsigned int'
type is an instance of:
enum Type
{
TYPE_FILE,
TYPE_FOLDER
};
find_data.nFileSizeLow is of type unsigned long
I am using GCC 3.4.0.
I don't understand that warning at all...the only problem I can see is if
the result of find_data.nFileSizeLow / 1024 is too big to fit in a long, but
the warning doesn't seem to be about that, or? (As a side note, I am not too
worried that the long will overflow in real-world use). I always like to
compile my code with warning level cranked up to max then I try to get rid
of most of warnings or at least understand them.
Thanks for any replies
/ WP