[build2] Problems with hash in multiline string

Boris Kolpackov boris at codesynthesis.com
Mon Nov 1 12:30:27 UTC 2021


Jörn Teuber via users <users at build2.org> writes:

> #include<iostream>
> int main()
> {
> std::cout<<R"(
> # test
> )";
> }
> 
> [...]
> 
> I feel like that might even be a bug in gcc, [...]

Yes, it's a bug that has been fixed in GCC 11.

If you want this construct (raw string literal containing lines that
start with `#`) to work with earlier versions of GCC, you will need
to force re-preprocessing:

obj{Test}: cc.reprocess = true


> [...] but as I don't understand what is going on in that first g++
> invocation [...]

That command does partial preprocessing of the source code (see GCC
-fdirectives-only documentation for details). build2 uses a different
compilation model compared to traditional build systems. You can read
more on that here:

https://build2.org/article/preprocess-compile-performance.xhtml



More information about the users mailing list