[build2] Problems with hash in multiline string

Jörn Teuber me at jaytea.org
Mon Nov 1 12:09:28 UTC 2021


Hello everyone,

I'm currently experimenting with build2 and came across a weird problem 
that can be reproduced with this Test.cpp:

#include<iostream>
intmain()
{
std::cout<<R"(
# test
)";
}

When executing 'b' on it I get

error: inconsistent C++ compiler behavior
   info: run the following two commands to investigate
   info: g++ -I/home/jay/Projects/Test-gcc/Test 
-I/home/jay/Projects/Test -std=c++2a -x c++ -MQ ^ -MD -E 
-fdirectives-only -MF /home/jay/Projects/Test-gcc/Test/Test/Test.o.t -o 
/home/jay/Projects/Test-gcc/Test/Test/Test.o.ii 
/home/jay/Projects/Test/Test/Test.cpp
   info: g++ -I/home/jay/Projects/Test-gcc/Test 
-I/home/jay/Projects/Test -std=c++2a -x c++ -MQ ^ -M -MG 
/home/jay/Projects/Test/Test/Test.cpp
   info: while extracting header dependencies from 
Test/cxx{Test}@../Test-gcc/Test/Test/
   info: while applying rule cxx.compile to update 
../Test-gcc/Test/Test/obje{Test}
   info: while applying rule cxx.link to update 
../Test-gcc/Test/Test/exe{Test}
   info: while applying rule alias to update ../Test-gcc/Test/dir{Test/}
   info: while applying rule alias to update ../Test-gcc/dir{Test/}
info: failed to update ../Test-gcc/dir{Test/}

Executing the first g++ line I get:

/home/jay/Projects/Test/Test/Test.cpp:9:3: error: invalid preprocessing 
directive #test
     9 | # test
       |   ^~~~

The second line runs perfectly fine.

I feel like that might even be a bug in gcc, but as I don't understand 
what is going on in that first g++ invocation I thought I first try this 
channel.

Best regards,
Jorn

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.build2.org/archives/users/attachments/20211101/dd3e4886/attachment.html>


More information about the users mailing list