<?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[[SOLVED] [QMake] How to conditionally compile code depending on debug&#x2F;release]]></title><description><![CDATA[<p dir="auto">In a large C++/Qt/QMake/qtcreator project I would like to perform some tests, but only when I am compiling with the debug flag.</p>
<p dir="auto">Is there a way to tell g++ that some small parts of the code have to be compiled only in debug mode ?</p>
<p dir="auto">I have tried things like this but without success..</p>
<p dir="auto">@<br />
#ifdef DEBUG<br />
cout &lt;&lt; "We are in Debug" &lt;&lt; endl;<br />
#else<br />
cout &lt;&lt; "We are in Release" &lt;&lt; endl;<br />
#endif<br />
@</p>
<p dir="auto">I guess I need to put the "DEBUG" flag somewhere in the QMake project, like:<br />
@<br />
CONFIG(release, debug|release) {<br />
TARGET = ffsm<br />
}<br />
CONFIG(debug, debug|release) {<br />
TARGET = ffsm_debug<br />
}<br />
@</p>
]]></description><link>https://forum.qt.io/topic/39281/solved-qmake-how-to-conditionally-compile-code-depending-on-debug-release</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 04:17:04 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/39281.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Mar 2014 15:36:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] [QMake] How to conditionally compile code depending on debug&#x2F;release on Thu, 20 Mar 2014 22:01:24 GMT]]></title><description><![CDATA[<p dir="auto">You're welcome !</p>
<p dir="auto">A little side note since you want do tests, you might be interested by the QTest framework</p>
<p dir="auto">Happy coding !</p>
]]></description><link>https://forum.qt.io/post/219288</link><guid isPermaLink="true">https://forum.qt.io/post/219288</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 20 Mar 2014 22:01:24 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] [QMake] How to conditionally compile code depending on debug&#x2F;release on Thu, 20 Mar 2014 15:57:08 GMT]]></title><description><![CDATA[<p dir="auto">thank you, it works the expected way...</p>
]]></description><link>https://forum.qt.io/post/219243</link><guid isPermaLink="true">https://forum.qt.io/post/219243</guid><dc:creator><![CDATA[sylvaticus]]></dc:creator><pubDate>Thu, 20 Mar 2014 15:57:08 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] [QMake] How to conditionally compile code depending on debug&#x2F;release on Thu, 20 Mar 2014 15:42:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">You can use</p>
<p dir="auto">@#ifdef QT_DEBUG<br />
// My debug related code<br />
#else<br />
// Release only code<br />
#endif@</p>
]]></description><link>https://forum.qt.io/post/219241</link><guid isPermaLink="true">https://forum.qt.io/post/219241</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 20 Mar 2014 15:42:01 GMT</pubDate></item></channel></rss>