Reputation: 23
Is there any way for the me to ask the vc++ compiler to show warnings when it encounters an explicit C-style cast in the following cases :
I'm turning on the UNICODE flag while compiling an application using the vc++ compiler and I want to avoid run time errors because of these casts.
Unfortunately the code base is large and I do not want to a manual search for casts and filter them out if they're invalid. I did try searching for documentation on this but nothing useful turned up.
Upvotes: 0
Views: 58
Reputation: 41
1- Open the project properties and set warning level to 4. 2- casting from wchar_t to char will be warned because you are trying to cast a large data to small one ( warning 4244 ). 3- casting from char to wchar_t will be warned only if you don't have set unsigned chars on(option /J), In this case char is a signed type and converting it to unsigned will produce warning (warning 4245 ).
Edit: This works for implicit cast. there is no compiler assistance to detect explicit legal casts
Upvotes: 1