-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
For info on /Zc:strictStrings see:
https://msdn.microsoft.com/en-us/library/dn449508.aspx
By default, Visual Studio allows for nonstandard C++ behaviour by allowing to assign string literals to non-const qualified types. For example, this is not standard:
TCHAR *nbCharLabel = TEXT("Characters (without blanks): ");
Standard requires such literal is const, so by definition it should not be possible to assign them like this. It's more than likely an attempt to write to the value pointed to by nbCharLabel will cause access violation.
/Zc:strictStrings enforces VS compiler to follow standard behaviour. Thus, it may be feasible to enable this switch for all compilation options (it's not exposed to project settings in 2015/2017, so it needs to be manually added to Command Line tab. When done, code will refuse to compile, throwing lots of errors (sadly, some of them are in ScintillaComponent - is it fine to fix things in there from within Notepad++). However, it's safe to just correct them - as if the code was relying on non-constness of such literals already, we'd end up with a crash any time code attempts to write to it. Thus, the only places which are not going to be trivially fixable (by adding a const qualifier to parameters and variables) are potential bugs in the code.