<?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[__FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren]]></title><description><![CDATA[<p>Hallo,</p>
<p>um meinen Debug-Output code zu komplettieren, würde ich gerne file, line und function informationen mit ausgeben.<br />
Ich definiere mir ein par short-hands:</p>
<pre><code>#ifndef __FUNCTION__
#define __FUNCTION__ &quot; &quot;
#endif

#ifndef __FILE__
#define __FILE__ &quot; &quot;
#endif

#ifndef __LINE__
#define __LINE__ &quot; &quot;
#endif

#ifndef __LPF__ //long pretty information about function 
#define __LPF__ __FILE__&lt;&lt;&quot;\n&quot;&lt;&lt;&quot;Line:&quot;&lt;&lt;__LINE__&lt;&lt;&quot;:&quot;&lt;&lt;__FUNCTION__&lt;&lt;&quot;\n&quot;
#endif

#ifndef __SPF__ //short pretty information about function 
#define __SPF__ __FUNCTION__&lt;&lt;&quot; in line &quot;&lt;&lt;__LINE__
#endif

#ifndef __F__ //short for function 
#define __F__ __FUNCTION__
#endif
</code></pre>
<p>jetzt kann ich mittels</p>
<pre><code>wcout &lt;&lt;&quot;INFO: &quot; &lt;&lt; 	__LPF__ &lt;&lt;endl;
</code></pre>
<p>Detailinformationen rausschreiben.</p>
<p>Gibt es eine Möglichkeit __LPF__ in einen wstring überzuführen?<br />
Ich könnte dann das ergebnis an eine methode übergeben.<br />
ICh habe ein parr tools, die in einem bestimmten format information in verschiedene files schreiben (z.b: log, info). wenn ich nun __LPF__ als argument beim aufruf mit übergeben könnte, könnte ich die die info, logfile gleich mit hinweisen zu zeilennummern etc. versehen.</p>
<p>Danke<br />
alex</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/251009/__file__-lt-lt-__line__-in-string-transferieren</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 18:52:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/251009.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Sep 2009 07:05:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to __FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren on Mon, 28 Sep 2009 07:05:51 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>um meinen Debug-Output code zu komplettieren, würde ich gerne file, line und function informationen mit ausgeben.<br />
Ich definiere mir ein par short-hands:</p>
<pre><code>#ifndef __FUNCTION__
#define __FUNCTION__ &quot; &quot;
#endif

#ifndef __FILE__
#define __FILE__ &quot; &quot;
#endif

#ifndef __LINE__
#define __LINE__ &quot; &quot;
#endif

#ifndef __LPF__ //long pretty information about function 
#define __LPF__ __FILE__&lt;&lt;&quot;\n&quot;&lt;&lt;&quot;Line:&quot;&lt;&lt;__LINE__&lt;&lt;&quot;:&quot;&lt;&lt;__FUNCTION__&lt;&lt;&quot;\n&quot;
#endif

#ifndef __SPF__ //short pretty information about function 
#define __SPF__ __FUNCTION__&lt;&lt;&quot; in line &quot;&lt;&lt;__LINE__
#endif

#ifndef __F__ //short for function 
#define __F__ __FUNCTION__
#endif
</code></pre>
<p>jetzt kann ich mittels</p>
<pre><code>wcout &lt;&lt;&quot;INFO: &quot; &lt;&lt; 	__LPF__ &lt;&lt;endl;
</code></pre>
<p>Detailinformationen rausschreiben.</p>
<p>Gibt es eine Möglichkeit __LPF__ in einen wstring überzuführen?<br />
Ich könnte dann das ergebnis an eine methode übergeben.<br />
ICh habe ein parr tools, die in einem bestimmten format information in verschiedene files schreiben (z.b: log, info). wenn ich nun __LPF__ als argument beim aufruf mit übergeben könnte, könnte ich die die info, logfile gleich mit hinweisen zu zeilennummern etc. versehen.</p>
<p>Danke<br />
alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1785197</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1785197</guid><dc:creator><![CDATA[AbsoluteBeginner_]]></dc:creator><pubDate>Mon, 28 Sep 2009 07:05:51 GMT</pubDate></item><item><title><![CDATA[Reply to __FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren on Mon, 28 Sep 2009 09:06:07 GMT]]></title><description><![CDATA[<p>AbsoluteBeginner_ schrieb:</p>
<blockquote>
<p>Gibt es eine Möglichkeit __LPF__ in einen wstring überzuführen?</p>
</blockquote>
<p>Ja, mit <a href="http://www.cplusplus.com/reference/iostream/ostringstream/" rel="nofollow">stringstreams</a>.<br />
Übrigens sind Bezeichner mit zwei Unterstrichen im Namen, und solche mit einem Unterstrich am Anfang, für den Compiler reserviert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1785236</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1785236</guid><dc:creator><![CDATA[Registrierter Troll]]></dc:creator><pubDate>Mon, 28 Sep 2009 09:06:07 GMT</pubDate></item><item><title><![CDATA[Reply to __FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren on Mon, 28 Sep 2009 09:20:07 GMT]]></title><description><![CDATA[<p>Danke für den Hinweis aud die stringstreams, und auf die unterstriche, werde dies ändern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1785242</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1785242</guid><dc:creator><![CDATA[AbsoluteBeginner_]]></dc:creator><pubDate>Mon, 28 Sep 2009 09:20:07 GMT</pubDate></item><item><title><![CDATA[Reply to __FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren on Mon, 28 Sep 2009 09:38:31 GMT]]></title><description><![CDATA[<p>Es geht auch ohne Laufzeitkosten (ich glaub nicht das Compiler Stringstream Operationen mit Konstanten wegoptimieren können):</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

// _m_str macht den inhalt eines macros zu einem string
#define _m_str_(a) #a
#define _m_str(a) _m_str_(a)

// _m_cat verbindet 2 code stücke (mit macro expansion)
#define _m_cat_(a,b) a##b
#define _m_cat(a,b) _m_cat_(a,b)

// wchar_t formen von __FUNCTION, __LINE__ und __FILE
#define W_FUNC _m_cat(L,__FUNCTION__)
#define W_LINE _m_cat(L,_m_str(__LINE__))
#define W_FILE _m_cat(L,__FILE__)

// zusammengesetzt
#define W_PRETTY W_FILE L&quot;\nLine:&quot; W_LINE L&quot;:&quot; W_FUNC L&quot;\n&quot;
#define W_PRETTY_SHORT W_FUNC L&quot; in line &quot; W_LINE

int main(int argc, char **argv)
{
	std::wcout &lt;&lt; W_PRETTY &lt;&lt; std::endl;
	std::wcout &lt;&lt; W_PRETTY_SHORT &lt;&lt; std::endl;

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1785251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1785251</guid><dc:creator><![CDATA[DerKuchen]]></dc:creator><pubDate>Mon, 28 Sep 2009 09:38:31 GMT</pubDate></item><item><title><![CDATA[Reply to __FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren on Mon, 28 Sep 2009 12:33:47 GMT]]></title><description><![CDATA[<p>... damit mir sowas nicht wieder passiert:<br />
wo finde ich denn eine übesicht bzgl. geschützer namen/bezeichner?</p>
<p>danke alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1785375</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1785375</guid><dc:creator><![CDATA[AbsoluteBeginner_]]></dc:creator><pubDate>Mon, 28 Sep 2009 12:33:47 GMT</pubDate></item><item><title><![CDATA[Reply to __FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren on Mon, 28 Sep 2009 12:49:31 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/18587">@DerKuchen</a>:<br />
Super! Vielen Dank für das ausführliche Beispiel!<br />
Ist schon 'eingebaut'.</p>
<p>Grüße<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1785389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1785389</guid><dc:creator><![CDATA[AbsoluteBeginner_]]></dc:creator><pubDate>Mon, 28 Sep 2009 12:49:31 GMT</pubDate></item><item><title><![CDATA[Reply to __FILE__&amp;lt;&amp;lt;__LINE__ in string transferieren on Mon, 28 Sep 2009 13:02:03 GMT]]></title><description><![CDATA[<p>AbsoluteBeginner_ schrieb:</p>
<blockquote>
<p>... damit mir sowas nicht wieder passiert:<br />
wo finde ich denn eine übesicht bzgl. geschützer namen/bezeichner?</p>
</blockquote>
<p>C++ Standard, Kapitel 2, inklusive der dortigen Verweise auf die anderen Kapitel. Besonders 2.10 und 2.11.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1785396</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1785396</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 28 Sep 2009 13:02:03 GMT</pubDate></item></channel></rss>