<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Clang does not actually perform a source translation for block literals. Instead, it generates code similar to what would have been generated had the user written the equivalent code.</div><div><br></div><div>There are many reasons why actually implementing this feature via source code translation would be difficult, but probably the most compelling is performance: there is really no reason for the compiler to go through all the work of parsing <i>new</i> source code when it already knows that it represents a block.</div><div><br></div><div>What do you actually need this for?</div><div>Jordan</div><div><br></div><br><div><div>On May 13, 2014, at 15:40 , Richard Catlin <<a href="mailto:richard.m.catlin@gmail.com">richard.m.catlin@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">For example, the Block Implementation Specification says<div><br></div><div><div><div style="margin: 0px; font-size: 7.5px; color: rgb(80, 132, 177);"><span style="color: rgb(121, 121, 121);">^ </span><span style="color: rgb(66, 66, 66);">{ printf(</span>"hello world\n"<span style="color: rgb(66, 66, 66);">); }</span></div></div><div><span style="color: rgb(66, 66, 66);"><br></span></div><div>is translated to<br><div><br></div><div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><span style="color: #00802a">struct </span>__block_literal_1 {</div><div style="margin: 0px; font-size: 7.5px; color: rgb(164, 48, 0);">void <span style="color: #797979">*</span><span style="color: #424242">isa;</span></div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><span style="color: #a43000">int </span>flags;</div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><span style="color: #a43000">int </span>reserved;</div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><span style="color: #a43000">void </span>(<span style="color: #797979">*</span>invoke)(<span style="color: #00802a">struct </span>__block_literal_1 <span style="color: #797979">*</span>);</div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><span style="color: #00802a">struct </span>__block_descriptor_1 <span style="color: #797979">*</span>descriptor;</div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);">};</div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><span style="color: #a43000">void </span><span style="color: #033a91">__block_invoke_1</span>(<span style="color: #00802a">struct </span>__block_literal_1 <span style="color: #797979">*</span>_block) {</div><div style="margin: 0px; font-size: 7.5px; color: rgb(80, 132, 177);"><span style="color: #424242">printf(</span>"hello world\n"<span style="color: #424242">);</span></div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);">}</div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><span style="color: #00802a">static struct </span>__block_descriptor_1 {</div><div style="margin: 0px; font-size: 7.5px; color: rgb(164, 48, 0);">unsigned long int <span style="color: #424242">reserved;</span></div><div style="margin: 0px; font-size: 7.5px; color: rgb(164, 48, 0);">unsigned long int <span style="color: #424242">Block_size;</span></div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);">} __block_descriptor_1 <span style="color: #797979">= </span>{ <span style="color: #4dae83">0</span>, <span style="color: #00802a">sizeof</span>(<span style="color: #00802a">struct </span>__block_literal_1), __block_invoke_1 };</div></div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><br></div><div style="margin: 0px; font-size: 7.5px; color: rgb(66, 66, 66);"><div style="margin: 0px; font-size: 7.5px;"><span style="color: #00802a">struct </span>__block_literal_1 _block_literal <span style="color: #797979">= </span>{</div><div style="margin: 0px; font-size: 7.5px;"><span style="color: #797979">&</span>_NSConcreteStackBlock,</div><div style="margin: 0px; font-size: 7.5px;">(<span style="color: #4dae83">1</span><span style="color: #797979"><<</span><span style="color: #4dae83">29</span>), <span style="color: #797979"><</span>uninitialized<span style="color: #797979">></span>,</div><div style="margin: 0px; font-size: 7.5px;">__block_invoke_1,</div><div style="margin: 0px; font-size: 7.5px;"><span style="color: #797979">&</span>__block_descriptor_1</div><div style="margin: 0px; font-size: 7.5px;">};</div><div style="margin: 0px; font-size: 7.5px;"><br></div><div style="margin: 0px; font-size: 7.5px;"><div>Thanks for any help.</div><div><span style="font-size: 12px;">Richard Catlin</span><br style="font-size: 12px;"><div style="font-size: 12px;"><div></div></div></div><div><span style="font-size: 12px;"><br></span></div></div></div></div></div></div>_______________________________________________<br>cfe-users mailing list<br><a href="mailto:cfe-users@cs.uiuc.edu">cfe-users@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users<br></blockquote></div><br></body></html>