[build2] [bug] Compilation error not visible in the reported file (wrong file reported?)

Boris Kolpackov boris at codesynthesis.com
Thu Mar 15 14:29:14 UTC 2018

Klaim - Joël Lamotte <mjklaim at gmail.com> writes:

> fatal error C1021: invalid preprocessor command 'to_string'

This appears to be a bug in VC's preprocessor's handling of raw string
literals. I've managed to reproduce the problem with this test case
(which I've reported to the VC folks):

cat <<EOF >test.cpp
const char* s = R"chaiscript(

# to_string for Pair()

def to_string(x) : call_exists(first, x) && call_exists(second, x) {
  "<" + x.first.to_string() + ", " + x.second.to_string() + ">";

# to_string for containers


cl.exe /nologo /EHsc /MD /P /WX /Fi: test.ii /TP test.cpp

I can't think of a way to work around this without modifying the
project's source code (e.g., to #ifdef-out this fragment during
the preprocessor run). Let me know if you are interested in this
approach and I will provide more information.

> 1. UX: The error report is not clear about which cpp file was being built
> (I get it in only in verbose 4, see below) or the target name being built
> (it's not clear in the verbose output).

You can see the exact command line that caused it with -V (aka
--verbose 3).

> Suggestion: consider adding the name of the target with an index of
> build and then  each log coming from it would be prefixed by this
> index (that's more or less what MSBUILD does,it's helpful; I believe
> ninja does this too?) Or anything to help identify in which context
> (aka the target) that specific cpp is built.

Yes, we have some ideas in this regard and will most likely implement
something at some point. Thanks for the suggestion.


More information about the users mailing list