<?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[Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge...]]></title><description><![CDATA[<p>Ich hab ein Klasse geschrieben und wollte diese jetzt in einem Hauptprogramm testen.</p>
<p>Diese Klasse ist so aufgebaut:</p>
<pre><code class="language-cpp">#ifndef LocalConnection
#define LocalConnection

class LocalConnection
{
      public:
             LocalConnection();
             ~LocalConnection();
             static int Connect( char* );
             static int Send( char* , char* );
             static int Close();
             static int Domain( char* );
             static int onStatus();

      private:

              static int   showListeners  ( void              );
              static int   checkListener  ( void              );
              static void  readMessage    ( void              );
              static int   writeAMFString ( char* , int       );
              static int   writeMessage   ( const char*       ); 
              static void  sendMessage    ( char*             );   
};

#endif
</code></pre>
<p>Wenn ich jetzt in der main eine Instanz der Klasse erzeugen will, kommen folgende Fehler, die auf die Datei &quot;LocalConnection.hpp&quot; verweisen:</p>
<p>LocalConnection.hpp: expected unqualified-id before ')' token<br />
(Zeigt auf die Zeile wo der Konstruktor steht)</p>
<p>LocalConnection.hpp: expected class-name before '(' token<br />
(Zeigt auf die Zeile in der der Destruktor steht)</p>
<p>LocalConnection.hpp: an anonymous union cannot have function members<br />
(Zeigt auf die &quot;{&quot; )</p>
<p>LocalConnection.hpp: abstract declarator `&lt;anonymous class&gt;' used as declaration</p>
<p>und</p>
<p>LocalConnection.hpp: namespace-scope anonymous aggregates must be static<br />
( Zeigen beide auf die &quot;}&quot; )</p>
<p>Kann ja sein das das eventuell ein Anfängerfehler ist aber ich weis wirklich nicht was der Compiler von mir will.<br />
(ich nutze Dev C++ 4.9.9.2)</p>
<p>mfg rendner</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/138086/compiler-meldet-quot-an-anonymous-union-cannot-have-function-members-quot-und-andere-dinge</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 00:44:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/138086.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Feb 2006 11:10:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge... on Thu, 23 Feb 2006 11:10:24 GMT]]></title><description><![CDATA[<p>Ich hab ein Klasse geschrieben und wollte diese jetzt in einem Hauptprogramm testen.</p>
<p>Diese Klasse ist so aufgebaut:</p>
<pre><code class="language-cpp">#ifndef LocalConnection
#define LocalConnection

class LocalConnection
{
      public:
             LocalConnection();
             ~LocalConnection();
             static int Connect( char* );
             static int Send( char* , char* );
             static int Close();
             static int Domain( char* );
             static int onStatus();

      private:

              static int   showListeners  ( void              );
              static int   checkListener  ( void              );
              static void  readMessage    ( void              );
              static int   writeAMFString ( char* , int       );
              static int   writeMessage   ( const char*       ); 
              static void  sendMessage    ( char*             );   
};

#endif
</code></pre>
<p>Wenn ich jetzt in der main eine Instanz der Klasse erzeugen will, kommen folgende Fehler, die auf die Datei &quot;LocalConnection.hpp&quot; verweisen:</p>
<p>LocalConnection.hpp: expected unqualified-id before ')' token<br />
(Zeigt auf die Zeile wo der Konstruktor steht)</p>
<p>LocalConnection.hpp: expected class-name before '(' token<br />
(Zeigt auf die Zeile in der der Destruktor steht)</p>
<p>LocalConnection.hpp: an anonymous union cannot have function members<br />
(Zeigt auf die &quot;{&quot; )</p>
<p>LocalConnection.hpp: abstract declarator `&lt;anonymous class&gt;' used as declaration</p>
<p>und</p>
<p>LocalConnection.hpp: namespace-scope anonymous aggregates must be static<br />
( Zeigen beide auf die &quot;}&quot; )</p>
<p>Kann ja sein das das eventuell ein Anfängerfehler ist aber ich weis wirklich nicht was der Compiler von mir will.<br />
(ich nutze Dev C++ 4.9.9.2)</p>
<p>mfg rendner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1000931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1000931</guid><dc:creator><![CDATA[rendner]]></dc:creator><pubDate>Thu, 23 Feb 2006 11:10:24 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge... on Thu, 23 Feb 2006 11:16:19 GMT]]></title><description><![CDATA[<p>Du definierst LocalConnection als Präprozessorsymbol ohne Inhalt. Damit bekommt der Compiler</p>
<pre><code class="language-cpp">class {
public:
  ();
  ~();
};
</code></pre>
<p>Also ich würd mich auch beschweren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>EDIT:<br />
Hups garnicht aufgefallen.<br />
Könnte natürlich auch daran liegen dass ANSI C keine Klassen kennt :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1000935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1000935</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Thu, 23 Feb 2006 11:16:19 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge... on Thu, 23 Feb 2006 11:28:40 GMT]]></title><description><![CDATA[<p>Oh man, das verstehe ich nicht...<br />
Wie kann ich den meinem Compiler sagen das er Klassen kennen soll, ich also dann nicht in ANSI C programmieren will.</p>
<p>Und was muss ich an den Konstruktor und Destruktor ändern damit die funktionieren, bin eigentlich der Meinung das ich das in C schon immer so gemacht hatte.</p>
<p>mfg rendner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1000950</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1000950</guid><dc:creator><![CDATA[rendner]]></dc:creator><pubDate>Thu, 23 Feb 2006 11:28:40 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge... on Thu, 23 Feb 2006 11:32:11 GMT]]></title><description><![CDATA[<p>Um C++ zu programmieren brauchst Du nen C++ Compiler. Hier ist das ANSI C Forum, da wird nicht über C++ geredet. Ob Du einen C++ Compiler hast, weiss ich nicht.</p>
<p>Ansonsten musst Du verhindern dass der Präprozessor dir das Wort LocalConnection löscht! (Vielleicht, möglicherweise, aber auch nur eventuell, indem man das Präprozessorsymbol nicht wie die Klasse nennt)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1000957</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1000957</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Thu, 23 Feb 2006 11:32:11 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge... on Thu, 23 Feb 2006 11:33:06 GMT]]></title><description><![CDATA[<p>rendner schrieb:</p>
<blockquote>
<p>Oh man, das verstehe ich nicht...</p>
</blockquote>
<p>Ist doch ganz einfach. Dein Includewächtersymbol heißt genauso wie deine Klasse. Das bewirkt, dass der Präprozessor deinen Klassennamen vor dem Compilieren aus dem Code löscht.</p>
<p>Du musst dein Includewächtersymbol so benennen, dass es nicht zu Namenskonflikten mit irgendwelchen Bezeichnern in deinem Code kommt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1000959</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1000959</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 23 Feb 2006 11:33:06 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge... on Thu, 23 Feb 2006 11:34:25 GMT]]></title><description><![CDATA[<p>LordJaxom schrieb:</p>
<blockquote>
<p>(Vielleicht, möglicherweise, aber auch nur eventuell, indem man das Präprozessorsymbol nicht wie die Klasse nennt)</p>
</blockquote>
<p>*rofl* <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1000960</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1000960</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Feb 2006 11:34:25 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler meldet: &amp;quot;an anonymous union cannot have function members &amp;quot; und andere Dinge... on Thu, 23 Feb 2006 11:35:58 GMT]]></title><description><![CDATA[<p>Man bin ich blöd :D...Danke, hab da gar nicht drauf geachtet.</p>
<p>mfg rendner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1000962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1000962</guid><dc:creator><![CDATA[rendner]]></dc:creator><pubDate>Thu, 23 Feb 2006 11:35:58 GMT</pubDate></item></channel></rss>