tags:

views:

156

answers:

1

SO, I am in the process of resolving the port of a 32bit app to 64 bit. When I compile for x64 I see a warning come up for the line ` CString sig; sig = "something"; sig = sig.left(strlen(something defined)); <<<<<<

` So, I get the warning for the sig.left where it implicitly converts the strlen value to int. Since in x64 strlen returns the 64bit size_t, i am getting the warning. what are my options of fixing this.. any alternate method ?

Thanks

+3  A: 

strlen always returns size_t. However, size_t is a different width on 64bit and 32bit operating systems.

CString.left, however, expects an int. Your code should be fine (provided your strings won't be too long to overrun an int value), but the compiler will warn you that you're causing this problem.

You can ignore the warning by using a cast. If you wanted to be "safe", you could do so by adding checking.

The required cast would be as simple as:

CString sig; 
sig = "something"; 
sig = sig.left((int)strlen(something_defined));
Reed Copsey
the short casting fixed my warning. But I want to explore re-writing it when there is time.
Gentoo