<?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[source-highlight aus c aufrufen]]></title><description><![CDATA[<p>hi,</p>
<p>ich würde gern source-highlight in meinem c-projekt verwenden. da ich jetzt nicht wegen einer lib alles durch einen c++ compiler jagen will, was evtl. auch nicht geht? hab ich mir überlegt, ich mach einfach von source-highlight eine c wrapper lib welche mir eine funktion anbietet, sollte doch möglich sein? den rest brauch ich eh nicht und wenn dann kompilier ich eben schnell die kleine wrapper lib neu.</p>
<p>probleme hab ich jetzt, da ich kein c++'ler bin mit der fehlerbehandlung. hab auch keine ahnung ob ich die richtigen klassen verwendet hab und wie man c++ librarys aus c aufruft... wär schön wenn da mal einer drüber schauen könnte, danke!</p>
<p>die funktion hätte ich gern 'exportiert' muß die in ein extern c gekapselt werden? denke nicht, ist ja c++ dabei, oder?</p>
<pre><code class="language-cpp">string_t *highlight(const char *type,const char *s,size_t len){
	if(highlight_is_valid_type(type)){
		try{
			std::string str(s,len);
			std::istringstream input(str);
			std::ostringstream output;
			std::string lang(type);
			lang.append(&quot;.lang&quot;);

			srchilite::SourceHighlight sourceHighlight(&quot;escaaa.outlang&quot;);
			sourceHighlight.setDataDir(&quot;/usr/share/source-highlight&quot;);
			sourceHighlight.setStyleCssFile(&quot;Hello2.css&quot;);
			sourceHighlight.highlight(input,output,lang);
			output.put(0);

			return string_dup_char((char*)output.str().c_str(),output.str().size());
		}catch(std::exception&amp; e){}
	}
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/302451/source-highlight-aus-c-aufrufen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 09:09:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/302451.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Apr 2012 06:58:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 06:58:06 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>ich würde gern source-highlight in meinem c-projekt verwenden. da ich jetzt nicht wegen einer lib alles durch einen c++ compiler jagen will, was evtl. auch nicht geht? hab ich mir überlegt, ich mach einfach von source-highlight eine c wrapper lib welche mir eine funktion anbietet, sollte doch möglich sein? den rest brauch ich eh nicht und wenn dann kompilier ich eben schnell die kleine wrapper lib neu.</p>
<p>probleme hab ich jetzt, da ich kein c++'ler bin mit der fehlerbehandlung. hab auch keine ahnung ob ich die richtigen klassen verwendet hab und wie man c++ librarys aus c aufruft... wär schön wenn da mal einer drüber schauen könnte, danke!</p>
<p>die funktion hätte ich gern 'exportiert' muß die in ein extern c gekapselt werden? denke nicht, ist ja c++ dabei, oder?</p>
<pre><code class="language-cpp">string_t *highlight(const char *type,const char *s,size_t len){
	if(highlight_is_valid_type(type)){
		try{
			std::string str(s,len);
			std::istringstream input(str);
			std::ostringstream output;
			std::string lang(type);
			lang.append(&quot;.lang&quot;);

			srchilite::SourceHighlight sourceHighlight(&quot;escaaa.outlang&quot;);
			sourceHighlight.setDataDir(&quot;/usr/share/source-highlight&quot;);
			sourceHighlight.setStyleCssFile(&quot;Hello2.css&quot;);
			sourceHighlight.highlight(input,output,lang);
			output.put(0);

			return string_dup_char((char*)output.str().c_str(),output.str().size());
		}catch(std::exception&amp; e){}
	}
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2203494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203494</guid><dc:creator><![CDATA[exilcubaner]]></dc:creator><pubDate>Thu, 19 Apr 2012 06:58:06 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 07:00:48 GMT]]></title><description><![CDATA[<p>exilcubaner schrieb:</p>
<blockquote>
<p>hab auch keine ahnung ob ich die richtigen klassen verwendet hab</p>
</blockquote>
<p>evtl. zur erklärung input ist normal ein istream und output ein ostream oder so. dadurch bekomm ich keine probleme, oder <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203495</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203495</guid><dc:creator><![CDATA[exilcubaner]]></dc:creator><pubDate>Thu, 19 Apr 2012 07:00:48 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 07:24:52 GMT]]></title><description><![CDATA[<p>exilcubaner schrieb:</p>
<blockquote>
<p>die funktion hätte ich gern 'exportiert' muß die in ein extern c gekapselt werden? denke nicht, ist ja c++ dabei, oder?</p>
</blockquote>
<p>so, das hätten wir schon mal...</p>
<blockquote>
<p>The C++ compiler must know that f(int,char,float) is to be called by a C compiler using the extern &quot;C&quot; construct:</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2203502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203502</guid><dc:creator><![CDATA[exilcubaner]]></dc:creator><pubDate>Thu, 19 Apr 2012 07:24:52 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 07:29:09 GMT]]></title><description><![CDATA[<p>habt ihr euch jetzt in eueren fuchsbau verzogen? wie auch immer ich geh kurz schlafen, bin krank. wenn ich aufsteh, hat sich hoffentlich einer rausgetraut <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203508</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203508</guid><dc:creator><![CDATA[exilcubaner]]></dc:creator><pubDate>Thu, 19 Apr 2012 07:29:09 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 08:55:55 GMT]]></title><description><![CDATA[<p>Eine halbe Stunde und Du maulst schon rum... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203546</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Thu, 19 Apr 2012 08:55:55 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 09:22:29 GMT]]></title><description><![CDATA[<p>Caligulaminus schrieb:</p>
<blockquote>
<p>Eine halbe Stunde und Du maulst schon rum... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
</blockquote>
<p>es sind inzwischen 2... aber wie dem auch sei, es klappt schon.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203568</guid><dc:creator><![CDATA[schlaflos]]></dc:creator><pubDate>Thu, 19 Apr 2012 09:22:29 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 19:01:47 GMT]]></title><description><![CDATA[<p>bump...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203804</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203804</guid><dc:creator><![CDATA[bumper]]></dc:creator><pubDate>Thu, 19 Apr 2012 19:01:47 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 19:07:27 GMT]]></title><description><![CDATA[<p>die offene frage ist, ob die funktion von c aus aufgerufen, bei einer geworfenen std::exception&amp; e 0 zurückgibt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203805</guid><dc:creator><![CDATA[spezifizierer]]></dc:creator><pubDate>Thu, 19 Apr 2012 19:07:27 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 19:37:11 GMT]]></title><description><![CDATA[<p>Ne, dann stürzt dein Programm vermutlich ab.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203812</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Thu, 19 Apr 2012 19:37:11 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 19:58:42 GMT]]></title><description><![CDATA[<p>und wie geht es dann richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203815</guid><dc:creator><![CDATA[exilcubaner]]></dc:creator><pubDate>Thu, 19 Apr 2012 19:58:42 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Thu, 19 Apr 2012 20:10:58 GMT]]></title><description><![CDATA[<p>so, jetzt hab ich ein anderes 'kosmetisches' problem</p>
<pre><code>#!/bin/sh

g++ -o libhighlight.o -c libhighlight.c
ar rcs libhighlight.a libhighlight.o
rm libhighlight.o

gcc -o test test.c -L. -lhighlight -lsource-highlight &amp;&amp; ./test
</code></pre>
<p>gibt es eine möglichkeit, -lsource-highlight wegzulassen find ich iwie unschön? hab schon versucht, das mit in das archiv zu packen, hat aber nicht geklappt. wenn ich das nicht verlinke, bekomm ich eine serie von fehlern?</p>
<pre><code>./libhighlight.a(libhighlight.o): In function `highlight':
libhighlight.c:(.text+0x129): undefined reference to `std::allocator&lt;char&gt;::allocator()'
libhighlight.c:(.text+0x149): undefined reference to `std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, unsigned ...
libhighlight.c:(.text+0x15a): undefined reference to `std::allocator&lt;char&gt;::~allocator()'
libhighlight.c:(.text+0x16e): undefined reference to `std::allocator&lt;char&gt;::~allocator()'
...
...
...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2203820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203820</guid><dc:creator><![CDATA[exilcubaner]]></dc:creator><pubDate>Thu, 19 Apr 2012 20:10:58 GMT</pubDate></item><item><title><![CDATA[Reply to source-highlight aus c aufrufen on Fri, 20 Apr 2012 01:53:58 GMT]]></title><description><![CDATA[<p>neuer tag neues glück...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2203846</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2203846</guid><dc:creator><![CDATA[_D]]></dc:creator><pubDate>Fri, 20 Apr 2012 01:53:58 GMT</pubDate></item></channel></rss>