Boost C++ Libraries: Ticket #4191: c++ library using regex included in objective-c needs rename of variable id https://svn.boost.org/trac10/ticket/4191 <p> Hey, </p> <p> I'm using a c++ lib containing a lot of boost stuff in a cocoa application and for this have to make it run in the "objective-c++"-hybrid. To compile this, there has to be some little variables, all called "id" be renamed in the files regex/v4/basic_regex_creator.hpp regex/v4/perl_matcher_common.hpp </p> <p> To test this: just include the header in a *.mm file and compile it with gcc -objc. By now, I've just recognized these two files using the reserved "id" as variable name. </p> <p> Many many thanks in advance </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4191 Trac 1.4.3 anonymous Wed, 05 May 2010 13:17:12 GMT attachment set https://svn.boost.org/trac10/ticket/4191 https://svn.boost.org/trac10/ticket/4191 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">patch_perl_matcher_common.patch</span> </li> </ul> Ticket anonymous Wed, 05 May 2010 13:17:29 GMT attachment set https://svn.boost.org/trac10/ticket/4191 https://svn.boost.org/trac10/ticket/4191 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">patch_basic_regex_creator.patch</span> </li> </ul> Ticket John Maddock Wed, 05 May 2010 17:40:12 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4191#comment:1 https://svn.boost.org/trac10/ticket/4191#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/61789" title="Change &#34;id&#34; to &#34;idx&#34; to be Objective C++ compatible. Fixes #2306. ...">[61789]</a>) Change "id" to "idx" to be Objective C++ compatible. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2306" title="#2306: Bugs: boost regex lib problems with ObjectiveC++ (closed: fixed)">#2306</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4132" title="#4132: Patches: Use of &#34;id&#34; as a variable name makes Boost unusable in Objective-C++ (closed: fixed)">#4132</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4191" title="#4191: Patches: c++ library using regex included in objective-c needs rename of variable id (closed: fixed)">#4191</a>. </p> Ticket anonymous Mon, 02 Aug 2010 11:59:15 GMT <link>https://svn.boost.org/trac10/ticket/4191#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:2</guid> <description> <p> I use FSF's gcc-4.2.4 objc++ compiler and, as opposed to Apple's compiler, this one also chokes on variables / template params with the name 'Protocol'. A simple workaround so far is to redefine these before including boost, but it's quite a mess. Would it be viable to change all instances of Protocol (and presumably protocol) also ;)? </p> <p> In any case, I can imagine someone coming across the same issue, the work-around is as follows: </p> <pre class="wiki">#define id cpp_id #define Protocol cpp_Protocol #include &lt;boost/asio.hpp&gt; #undef id #undef Protocol </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Mon, 02 Aug 2010 16:53:20 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/4191#comment:3 https://svn.boost.org/trac10/ticket/4191#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> Ticket John Maddock Mon, 02 Aug 2010 16:56:37 GMT owner, status, component changed https://svn.boost.org/trac10/ticket/4191#comment:4 https://svn.boost.org/trac10/ticket/4191#comment:4 <ul> <li><strong>owner</strong> changed from <span class="trac-author">John Maddock</span> to <span class="trac-author">chris_kohlhoff</span> </li> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> <li><strong>component</strong> <span class="trac-field-old">regex</span> → <span class="trac-field-new">asio</span> </li> </ul> <p> Re-opening and re-assigning to Asio as that's the library affected in this new case. </p> <p> I have a suspicion that the answer to this one may be "won't fix" though - "protocol" is just such a heavily used name - and frankly why not! </p> <p> John. </p> Ticket chris_kohlhoff Fri, 22 Oct 2010 12:07:44 GMT <link>https://svn.boost.org/trac10/ticket/4191#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:5</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66143" title="Redefine Protocol and id to avoid clashing with Objective-C++ ...">[66143]</a>) Redefine Protocol and id to avoid clashing with Objective-C++ keywords. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4191" title="#4191: Patches: c++ library using regex included in objective-c needs rename of variable id (closed: fixed)">#4191</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 25 Oct 2010 10:44:41 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4191#comment:6 https://svn.boost.org/trac10/ticket/4191#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66173" title="Merge from trunk. ........ r66075 | chris_kohlhoff | 2010-10-18 ...">[66173]</a>) Merge from trunk. ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66075" title="Fix unused parameter warnings. ">r66075</a> | chris_kohlhoff | 2010-10-18 23:27:12 +1100 (Mon, 18 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix unused parameter warnings. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66143" title="Redefine Protocol and id to avoid clashing with Objective-C++ ...">r66143</a> | chris_kohlhoff | 2010-10-22 23:07:36 +1100 (Fri, 22 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Redefine Protocol and id to avoid clashing with Objective-C++ keywords. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4191" title="#4191: Patches: c++ library using regex included in objective-c needs rename of variable id (closed: fixed)">#4191</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66144" title="Version check not required. ">r66144</a> | chris_kohlhoff | 2010-10-22 23:20:52 +1100 (Fri, 22 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Version check not required. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66156" title="Fix for IBM C++ compiler. ">r66156</a> | chris_kohlhoff | 2010-10-24 11:26:10 +1100 (Sun, 24 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix for IBM C++ compiler. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66158" title="Fix vector reallocation performance problem. Refs #4780. ">r66158</a> | chris_kohlhoff | 2010-10-24 13:06:46 +1100 (Sun, 24 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix vector reallocation performance problem. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4780" title="#4780: Bugs: Many deadline_timer objects triggers worst-case vector reallocation in ... (closed: fixed)">#4780</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66159" title="Fix kqueue_reactor so that it compiles on NetBSD. Refs #4662. ">r66159</a> | chris_kohlhoff | 2010-10-24 18:58:23 +1100 (Sun, 24 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix kqueue_reactor so that it compiles on NetBSD. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4662" title="#4662: Bugs: asio is not usable on NetBSD (using kqueue) (closed: fixed)">#4662</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66162" title="Fix failure in socket_base test on NetBSD. ">r66162</a> | chris_kohlhoff | 2010-10-25 00:15:46 +1100 (Mon, 25 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix failure in socket_base test on NetBSD. </p> </blockquote> <p> ........ </p> Ticket anonymous Fri, 29 Oct 2010 21:34:44 GMT <link>https://svn.boost.org/trac10/ticket/4191#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:7</guid> <description> <p> Comments for <a class="changeset" href="https://svn.boost.org/trac10/changeset/66143" title="Redefine Protocol and id to avoid clashing with Objective-C++ ...">r66143</a><br /> </p> <p> Protocol and id are not macros, <br /> so they should be #undef'ed in detail/pop_options.hpp: </p> <pre class="wiki"> # if defined(__OBJC__) # undef Protocol # pragma pop_macro("Protocol") # undef id # pragma pop_macro("id") # endif </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 29 Oct 2010 21:36:30 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/4191#comment:8 https://svn.boost.org/trac10/ticket/4191#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> Ticket chris_kohlhoff Fri, 29 Oct 2010 23:41:38 GMT <link>https://svn.boost.org/trac10/ticket/4191#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4191#comment:7" title="Comment 7">anonymous</a>: </p> <blockquote class="citation"> <p> Comments for <a class="changeset" href="https://svn.boost.org/trac10/changeset/66143" title="Redefine Protocol and id to avoid clashing with Objective-C++ ...">r66143</a><br /> </p> <p> Protocol and id are not macros, <br /> so they should be #undef'ed in detail/pop_options.hpp: </p> <pre class="wiki"> # if defined(__OBJC__) # undef Protocol # pragma pop_macro("Protocol") # undef id # pragma pop_macro("id") # endif </pre></blockquote> <p> AFAIK, they are macros as far as pop_macro is concerned. If you see a problem then please provide a test case. </p> <p> The following source file "test.mm": </p> <pre class="wiki">#include &lt;boost/asio.hpp&gt; #ifdef Protocol # error Protocol is defined #endif #ifdef id # error id is defined #endif </pre><p> compiles without error or warning using gcc 4.4.5. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 30 Oct 2010 09:48:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4191#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:10</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4191#comment:9" title="Comment 9">chris_kohlhoff</a>: </p> <blockquote class="citation"> <p> AFAIK, they are macros as far as pop_macro is concerned. If you see a problem then please provide a test case. </p> </blockquote> <p> With your "test.mm" (tested using gcc 4.0, 4.2, 4.4 on Mac OS X 10.5), <br /> warnings ("warning: ignoring #pragma pop_macro", "warning: ignoring #pragma pop_macro") and errors ("error: #error Protocol is defined", "error: #error id is defined") are emitted. <br /> </p> <p> As a side note, this only happens on the trunk and NOT on the Boost 1.44. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 30 Oct 2010 10:23:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4191#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:11</guid> <description> <p> Sorry, in the above comment, there is a typo: <br /> warnings ("warning: ignoring #pragma pop_macro", "warning: ignoring #pragma pop_macro") <br /> --&gt; <br /> warnings ("warning: ignoring #pragma push_macro", "warning: ignoring #pragma pop_macro") <br /> </p> <p> In Objective-C++, "id" is a typedef and not a macro. <br /> So unless the user #define's "id", <br /> '#pragma push_macro("id")' in push_options.hpp and '#pragma pop_macro("id")' in pop_options.hpp do not make any effect, <br /> and thus the macro '#define id cpp_id' in push_options.hpp is still valid after pop_macro. <br /> </p> <p> Ditto for "Protocol". </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 04 Nov 2010 09:46:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4191#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:12</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4191#comment:11" title="Comment 11">anonymous</a>: </p> <blockquote class="citation"> <p> So unless the user #define's "id", '#pragma push_macro("id")' in push_options.hpp and '#pragma pop_macro("id")' in pop_options.hpp do not make any effect, and thus the macro '#define id cpp_id' in push_options.hpp is still valid after pop_macro. <br /> </p> </blockquote> <p> This was wrong; This happened simply because the pragmas push_macro and pop_macro are not implemented on the tested compilers. After updating gcc from 4.4.1 (MacPorts) to 4.4.5 (MacPorts), "test.mm" gets successfully compiled with <a class="changeset" href="https://svn.boost.org/trac10/changeset/66143" title="Redefine Protocol and id to avoid clashing with Objective-C++ ...">r66143</a>. However, with <a class="changeset" href="https://svn.boost.org/trac10/changeset/66289" title="Target workaround at non-Apple objective-c++ compilers only, as the ...">r66289</a>, compiling "test.mm" using MacPorts gcc 4.4.5 fails again (see below). </p> <p> Comments about <a class="changeset" href="https://svn.boost.org/trac10/changeset/66289" title="Target workaround at non-Apple objective-c++ compilers only, as the ...">r66289</a>, <br /> MacPorts gcc's are non-apple compilers, but they seem to have __APPLE_CC__ macros. While __APPLE_CC__ is defined as 1 in MacPorts gcc's, Apple gcc's define __APPLE_CC__ as the build numbers (e.g. 5488 and 5564). So it might be better to use </p> <pre class="wiki">!(defined(__APPLE_CC__) &amp;&amp; __APPLE_CC__ &gt; 1) </pre><p> for detecting non-Apple compilers. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Thu, 04 Nov 2010 11:43:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4191#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4191#comment:13</guid> <description> <p> Please try <a class="changeset" href="https://svn.boost.org/trac10/changeset/66398" title="MacPorts gcc also defines __APPLE_CC__, but to 1. ">[66398]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 04 Nov 2010 12:18:25 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4191#comment:14 https://svn.boost.org/trac10/ticket/4191#comment:14 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/66398" title="MacPorts gcc also defines __APPLE_CC__, but to 1. ">r66398</a>. </p> <p> Chris, great thanks for your work! </p> Ticket chris_kohlhoff Thu, 04 Nov 2010 12:21:42 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/4191#comment:15 https://svn.boost.org/trac10/ticket/4191#comment:15 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Not closing until merged to release. </p> Ticket chris_kohlhoff Fri, 12 Nov 2010 23:32:41 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4191#comment:16 https://svn.boost.org/trac10/ticket/4191#comment:16 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66554" title="Merged objective c++ fix from tunk. Fixes #4191. ........ r66289 | ...">[66554]</a>) Merged objective c++ fix from tunk. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4191" title="#4191: Patches: c++ library using regex included in objective-c needs rename of variable id (closed: fixed)">#4191</a>. </p> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66289" title="Target workaround at non-Apple objective-c++ compilers only, as the ...">r66289</a> | chris_kohlhoff | 2010-10-31 09:45:29 +1100 (Sun, 31 Oct 2010) | 4 lines </p> </blockquote> <p> </p> <blockquote> <p> Target workaround at non-Apple objective-c++ compilers only, as the previous workaround broke those platforms. Pragmas push_macro and pop_macro are only available on gcc 4.4 or later, so use plain ol' #define/#undef instead. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66398" title="MacPorts gcc also defines __APPLE_CC__, but to 1. ">r66398</a> | chris_kohlhoff | 2010-11-04 22:40:42 +1100 (Thu, 04 Nov 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> <a class="missing wiki">MacPorts</a> gcc also defines <span class="underline">APPLE_CC</span>, but to 1. </p> </blockquote> <p> ........ </p> Ticket