stray quotation marks warning enhancement or extension
Manuel López-Ibáñez
lopezibanez@gmail.com
Fri Apr 1 14:33:00 GMT 2016
On 31/03/16 23:23, Jonathan Wakely wrote:
> On 31 March 2016@21:10, Daniel Gutson wrote:
>> Hi,
>>
>> many times we copy code snippets from sources that change the
>> Unicode quotation marks ( “ ” ) rather than " ". For example
>>
>> const std::string a_string(“Hello”);
>>
>> That line looks innocent but causes gcc to say
>>
>> xxxxx.cpp:4:1: error: stray ‘\342’ in program
>> const std::string a_string(“Hello”);
>> ^
>>
>> misleading the poor programmer with such error message and wrong
>> column. A quick Google search says there are 171,000 matches for "
>> error: stray ‘\342’ in program" which may show that this is a very
>> common issue.
[...]
>> * improve the error message for the case of the Unicode quotes such
>> as adding "(seems Unicode quotes where used)"
>
> IMHO this would be better.
Note that GCC 6.0 has the capability of issuing something like:
xxxxx.cpp:4:28: error: Unicode quotation marks ‘\342’ are not valid
const std::string a_string(“Hello”);
^
"
or even:
xxxxx.cpp:4:28: error: Unicode quotation marks ‘\342’ are not valid
const std::string a_string(“Hello”);
^~~~~~~
"Hello"
Smart editors might be able to apply the fix automatically given the above.
Cheers,
Manuel.
More information about the Gcc
mailing list