PREfast Warning 284 (Windows CE 5.0)
284 - Format string mismatch.
Additional Information: Object passed when string is required in call to <function>.
Consequence: Object will be converted to integer, not string.
This warning indicates that the format string specifies that a string is required (for example, a %s specification for printf or scanf) but a C++ object has been passed instead.
This defect is likely to result in a crash or corruption of some form. Even if the code behaves correctly on 32-bit architectures, it is likely to cause problems when porting to 64-bit architectures.
This message is often reported because of passing a C++ object implementing some string type (for example, std::string, CComBSTR, or _bstr_t) into a C printf-style call.
Depending on the implementation of the C++ class (that is, if the proper cast operators are defined), C++ string objects can often be used transparently when C strings are required. However, because parameters to printf-style functions are essentially untyped, no conversion to a string occurs.
Depending on the object, it might be appropriate to insert a static_cast operator to the appropriate string type (for example, char * or TCHAR *) or to call a member function that returns a string (for example, c_str(), on instances of std::string).
Example
Defective Source
CComBSTR bstrValue;
sprintf(buff,
"The string is : %S",
bstrValue);
Corrected Source
CComBSTR bstrValue;
sprintf(buff,
"The string is : %S",
static_cast<BSTR>(bstrValue));
Send Feedback on this topic to the authors