<?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[Die Pascal with-Anweisung auch für c und c++?]]></title><description><![CDATA[<p>Hallo Leute!</p>
<p>In Pascal gibt es die with-Anweisung, um dort record-Gesamtnamen einzusparen.<br />
Gibt es eine ähnliche Anweisung in c/c++, welche zum Beispiel bei<br />
Strukturvariablen den Gesamtnamen abkürzen könnte?<br />
Beispiel:</p>
<pre><code>struct _dreieck
{
 long double a, aq, att, b, bq, qt, h, ht, hq, c, p, pq, q, laufende;
} triangle;
</code></pre>
<p>Aufruf mit:</p>
<pre><code>triangle.hq = triangle.p * triangle.q;
triangle.h = sqrtl(triangle.hq);
triangle.aq = triangle.hq + (triangle.p * triangle.p);
triangle.att = sqrtl(triangle.aq);
</code></pre>
<p>So das mit der (gewünschten) Anweisung verkürzt werden könnte, damit man<br />
sich keinen Wolf tippt.<br />
etwa so:</p>
<pre><code>with triangle
{
hq = p * q;
h = sqrtl(hq);
aq = hq + (p * p);
att = sqrtl(aq);
}
</code></pre>
<p>Ich arbeite mit gcc und Linux mit codeblocks 16.01.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/336625/die-pascal-with-anweisung-auch-für-c-und-c</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 05:24:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/336625.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Feb 2016 18:50:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 18:50:45 GMT]]></title><description><![CDATA[<p>Hallo Leute!</p>
<p>In Pascal gibt es die with-Anweisung, um dort record-Gesamtnamen einzusparen.<br />
Gibt es eine ähnliche Anweisung in c/c++, welche zum Beispiel bei<br />
Strukturvariablen den Gesamtnamen abkürzen könnte?<br />
Beispiel:</p>
<pre><code>struct _dreieck
{
 long double a, aq, att, b, bq, qt, h, ht, hq, c, p, pq, q, laufende;
} triangle;
</code></pre>
<p>Aufruf mit:</p>
<pre><code>triangle.hq = triangle.p * triangle.q;
triangle.h = sqrtl(triangle.hq);
triangle.aq = triangle.hq + (triangle.p * triangle.p);
triangle.att = sqrtl(triangle.aq);
</code></pre>
<p>So das mit der (gewünschten) Anweisung verkürzt werden könnte, damit man<br />
sich keinen Wolf tippt.<br />
etwa so:</p>
<pre><code>with triangle
{
hq = p * q;
h = sqrtl(hq);
aq = hq + (p * p);
att = sqrtl(aq);
}
</code></pre>
<p>Ich arbeite mit gcc und Linux mit codeblocks 16.01.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485885</guid><dc:creator><![CDATA[rustyoldguy]]></dc:creator><pubDate>Thu, 04 Feb 2016 18:50:45 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:03:10 GMT]]></title><description><![CDATA[<p>Nein gibt es nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485889</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:09:42 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/u109509" rel="nofollow">SeppJ</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/f10" rel="nofollow">C (alle ISO-Standards)</a> in das Forum <a href="http://www.c-plusplus.net/forum/f15" rel="nofollow">C++ (alle ISO-Standards)</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485890</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:09:42 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:17:29 GMT]]></title><description><![CDATA[<p>rustyoldguy schrieb:</p>
<blockquote>
<p>c/c++</p>
</blockquote>
<p>Diese Sprache gibt es nicht. C und C++ sind zwei ganz unterschiedliche Sprachen.</p>
<p>Aber auch in C++ ist die Antwort: Nein, gibt es nicht. Dazu sind Klassenmethoden da. Unter Schmerzen kann man sich vielleicht sogar was zurecht hacken, das einen ähnlichen Effekt hätte. Ist aber nicht empfehlenswert.</p>
<p>Diese Frage hätte man übrigens wunderbar googeln können. Es gibt Dutzende treffende Antworten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485893</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:17:29 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:18:46 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Dazu sind Klassenmethoden da.</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485895</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:18:46 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:27:16 GMT]]></title><description><![CDATA[<p>PS: Da Googeln nicht so Jedermanns Sache ist, hier ein &quot;schöner&quot; Hack, den jemand auf Stackoverflow vorgeschlagen hat:<br />
<a href="http://stackoverflow.com/questions/2279180/does-c-have-with-keyword-like-pascal/2279253#2279253" rel="nofollow">http://stackoverflow.com/questions/2279180/does-c-have-with-keyword-like-pascal/2279253#2279253</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485896</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:27:16 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:46:34 GMT]]></title><description><![CDATA[<p>Wenn man nach soetwas googelt, mag man die Antwort nicht immer gleich glauben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> Es kann durchaus sein, dass es halbwegs sinnvolle Antworten gibt, die man erst nach einer Weile findet (ok, jetzt nicht unbedingt zu dem Thema).<br />
Ich hab früher Delphi programmiert und es hat mich auch interessiert, als ich auf C++ umgestiegen bin. Aber eigentlich ist es keine gute Idee, Tipparbeit sparen zu wollen und ich hab das Feature nie vermisst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485902</guid><dc:creator><![CDATA[Mechanics]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:46:34 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:50:41 GMT]]></title><description><![CDATA[<p>Denkst du etwas das sind alle Trolle? <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/2485904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485904</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:50:41 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Thu, 04 Feb 2016 19:55:42 GMT]]></title><description><![CDATA[<p>Stackoverflow ist wegen seiner Selbstregulierung doch relativ zuverlässig, was die Qualität der Antworten angeht.</p>
<p>~Jetzt darf jeder mal das krasseste Gegenbeispiel zum besten geben, wo eine gute Antwort niedergemacht wurde oder, noch viel schlimmer, wo die eigene Antwort niedergemacht wurde.~</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485907</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 04 Feb 2016 19:55:42 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Fri, 05 Feb 2016 17:32:30 GMT]]></title><description><![CDATA[<p>Hallo roflo!</p>
<p>Da ich einige schwere Hand-Verletzungen durch Arbeitsunfälle als<br />
Metallarbeiter hatte, wäre für mich eine solche Anweisung in c<br />
wünschenswert, nicht nur WITH.</p>
<p>Pascal scheint seit einiger Zeit &quot;out&quot; zu sein.<br />
Pascal hatte aber Vorteile, beispielsweise bei der Portierung von Code.<br />
Der ist anscheinend bei c/c++ schwerer zu portieren als Pascal,<br />
je nach Compiler-Hersteller. Ebenso hat Pascal oberhalb der<br />
Funktionsebene Assemblerniveau. Oft ist es auch in C nicht möglich<br />
einen String als WERT zu erhalten oder zurückzugeben.<br />
Dazu kommen die Unterschiede bei der Typ-Prüfung der Parameter und deren<br />
Übergabe bei C (von rechts nach links auf den Stack) und bei Pascal(ist es umgekehrt, von links nach rechts).<br />
Ob dies dann besser ist, da Pascal den Stackpointer selber vor<br />
dem Rücksprung zum Code zurücksetzen muss, bleibt Glaubenssache.<br />
Die Unterschiede bei den Variablentypen finde ich, sind ganz okay.<br />
Viele Sachen sind bei c und c++ in den letzten Jahren besser geworden<br />
und lassen sich mit Schlüsselwörtern und Einstellungen &quot;ausmerzen&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2485998</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2485998</guid><dc:creator><![CDATA[rustyoldguy]]></dc:creator><pubDate>Fri, 05 Feb 2016 17:32:30 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Fri, 05 Feb 2016 17:55:47 GMT]]></title><description><![CDATA[<p>Not sure if trolling...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2486001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2486001</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 05 Feb 2016 17:55:47 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Fri, 05 Feb 2016 19:17:48 GMT]]></title><description><![CDATA[<p>rustyoldguy schrieb:</p>
<blockquote>
<p>Viele Sachen sind bei c und c++ in den letzten Jahren besser geworden<br />
und lassen sich mit Schlüsselwörtern und Einstellungen &quot;ausmerzen&quot;.</p>
</blockquote>
<pre><code>#define BEGIN {
#define END }
</code></pre>
<p>Und es gibt keinen Smiley, der meine Gefühle dazu ausdrückt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2486007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2486007</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 05 Feb 2016 19:17:48 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Fri, 05 Feb 2016 19:45:28 GMT]]></title><description><![CDATA[<p>Du suchst: <a href="http://comps.canstockphoto.de/can-stock-photo_csp28487942.jpg" rel="nofollow">http://comps.canstockphoto.de/can-stock-photo_csp28487942.jpg</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2486012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2486012</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Fri, 05 Feb 2016 19:45:28 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Sat, 06 Feb 2016 02:54:05 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>PS: Da Googeln nicht so Jedermanns Sache ist, hier ein &quot;schöner&quot; Hack, den jemand auf Stackoverflow vorgeschlagen hat:<br />
<a href="http://stackoverflow.com/questions/2279180/does-c-have-with-keyword-like-pascal/2279253#2279253" rel="nofollow">http://stackoverflow.com/questions/2279180/does-c-have-with-keyword-like-pascal/2279253#2279253</a></p>
</blockquote>
<p>Der Hack ist nur leider fast nutzlos, da</p>
<ul>
<li>nur auf einer Kopie des Objekts agiert wird,</li>
<li>lokale Variablen nicht verwendet werden können.</li>
</ul>
<p>Ist sozusagen nur ein PoC für die Syntax. Könnte deutlich interessanter werden, sobald Aliasing entsprechend angepasst wird ([basic.lval]/(10.6) könnte erweitert werden).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2486043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2486043</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 06 Feb 2016 02:54:05 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Sat, 06 Feb 2016 11:30:39 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Dazu sind Klassenmethoden da.</p>
</blockquote>
<p>so isses:</p>
<pre><code>struct _dreieck
{
 long double a, aq, att, b, bq, qt, h, ht, hq, c, p, pq, q, laufende;
 void update();
} triangle;

void _dreieck::update()
{
    hq = p * q;
    h = sqrtl(hq);
    aq = hq + (p * p);
    att = sqrtl(aq);
}
// und später dann
    triangle.update();
</code></pre>
<p>im Übrigen kannst Du einiges an Tipparbeit sparen, indem Du einige Variablen einfach weg lässt. Ich vermute, dass Du nicht alle benötigst, dazu müsste man aber das Problem besser kennen.<br />
Was ist z.B. der Unterschied zwischen <code>att</code> und <code>a</code> ?</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2486072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2486072</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sat, 06 Feb 2016 11:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Sat, 06 Feb 2016 12:13:58 GMT]]></title><description><![CDATA[<p>rustyoldguy schrieb:</p>
<blockquote>
<p>In Pascal gibt es die with-Anweisung, um dort record-Gesamtnamen einzusparen.</p>
</blockquote>
<p>Die ist übrigens in modernen Pascal-Dialekten zu Recht verpönt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2486075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2486075</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Sat, 06 Feb 2016 12:13:58 GMT</pubDate></item><item><title><![CDATA[Reply to Die Pascal with-Anweisung auch für c und c++? on Sat, 06 Feb 2016 14:33:27 GMT]]></title><description><![CDATA[<p>Also, wenn es tatsächlich bitter nötig zu sein scheint, ließe sich durchaus etwas basteln:</p>
<pre><code>#include &lt;boost/preprocessor/seq/enum.hpp&gt;
#include &lt;boost/preprocessor/seq/for_each.hpp&gt;
#include &lt;boost/preprocessor/tuple/to_seq.hpp&gt;

#define WITH_DECLARATION(r, data, elem) \
	if (bool _loop_cond = false); else for (auto&amp; elem = data.elem; !_loop_cond; _loop_cond = true)
#define WITH(d, ...) BOOST_PP_SEQ_FOR_EACH(WITH_DECLARATION, d, BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__)))

//! TEST

#include &lt;iostream&gt;
#include &lt;cmath&gt;

#define DREIECK_MEMBERS a, aq, att, b, bq, qt, h, ht, hq, c, p, pq, q, laufende
struct dreieck {
	long double DREIECK_MEMBERS;
} triangle;
#define WITH_DREIECK(t) WITH(t, DREIECK_MEMBERS)

int main() {
	WITH_DREIECK(triangle) {
		hq = p * q;
		h = sqrtl(hq);
		aq = hq + (p * p);
		att = sqrtl(aq);
	};
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2486080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2486080</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 06 Feb 2016 14:33:27 GMT</pubDate></item></channel></rss>