<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[moc.exe cannot parse double quotes in c++ raw string correctly]]></title><description><![CDATA[<p dir="auto">I have a very simple class TestRawString that inherits from QObject and I'm running into the infamous <strong>'undefined reference to vtable'</strong> error in the constructor and destructor of TestRawString.</p>
<p dir="auto">The moc build step to generate moc_TestRawString.cpp results in the following:<br />
TestRawString.h:0:1: note: <strong>No relevant classes found. No output generated.</strong><br />
and indeed, moc_TestRawString.cpp is an empty file.</p>
<p dir="auto"><strong>Once I comment the variable "raw_double_quotes" in TestRawString.h, the project will compile and run correctly.</strong> Is it a feature or something?</p>
<p dir="auto">This phenomenon is easy to reproduce and here are my example codes.</p>
<p dir="auto">TestRawString.h</p>
<pre><code>#include &lt;QObject&gt;
class TestRawString : public QObject
{
    Q_OBJECT
public:
    explicit TestRawString(QObject *parent = nullptr);
    std::string raw_double_quotes = R"++(")++";
    std::string raw_single_quote = R"++(')++";
    std::string normal_double_quotes = "\"";
};

</code></pre>
<p dir="auto">TestRawString.cpp (generated by Qt)</p>
<pre><code>#include "TestRawString.h"

TestRawString::TestRawString(QObject *parent)
    : QObject{parent}
{}

</code></pre>
<p dir="auto">main.cpp</p>
<pre><code>#include "TestRawString.h"

int main()
{
    TestRawString trs;
    assert(trs.normal_double_quotes == R"++(")++");
    return 0;
}

</code></pre>
<p dir="auto">.pro</p>
<pre><code>QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle

HEADERS += \
    TestRawString.h

SOURCES += \
        TestRawString.cpp \
        main.cpp

</code></pre>
<p dir="auto">enviroment:</p>
<pre><code>Qt: (online installation)
QMake version 3.1
Using Qt version 6.2.4 in C:/Qt/Qt6.2/6.2.4/mingw_64/lib

compiler: gcc version 11.2.0 (x86_64-posix-seh-rev3, Built by MinGW-W64 project)

os: windows 10 21H2 x86_64
</code></pre>
]]></description><link>https://forum.qt.io/topic/136476/moc-exe-cannot-parse-double-quotes-in-c-raw-string-correctly</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 21:51:40 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/136476.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 13 May 2022 02:05:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to moc.exe cannot parse double quotes in c++ raw string correctly on Fri, 13 May 2022 03:31:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kagami-0">@<bdi>kagami-0</bdi></a> said in <a href="/post/713932">moc.exe cannot parse double quotes in c++ raw string correctly</a>:</p>
<blockquote>
<p dir="auto">Is it a feature or something?</p>
</blockquote>
<p dir="auto">It's a limitation of moc.</p>
<p dir="auto">As a workaround, initialize the raw string in a .cpp file, or use a non-raw escaped string.</p>
]]></description><link>https://forum.qt.io/post/713935</link><guid isPermaLink="true">https://forum.qt.io/post/713935</guid><dc:creator><![CDATA[JKSH]]></dc:creator><pubDate>Fri, 13 May 2022 03:31:14 GMT</pubDate></item></channel></rss>