Boost C++ Libraries: Ticket #5725: Different ordering of includes can lead to compilation errors ( ‘SEEK_SET’ cannot appear in a constant-expression etc ) https://svn.boost.org/trac10/ticket/5725 <p> Hi, </p> <p> I've got a problem with compiling an extremely simple program on one machine while there is no problem on another one. The program is: </p> <pre class="wiki">#include &lt;boost/asio.hpp&gt; #include &lt;boost/mpi.hpp&gt; #include &lt;boost/interprocess/sync/interprocess_semaphore.hpp&gt; int main(){ return 0; } </pre><p> I get these errors: </p> <pre class="wiki">/usr/local/include/boost/interprocess/detail/os_file_functions.hpp:363:33: error: ‘SEEK_SET’ cannot appear in a constant-expression /usr/local/include/boost/interprocess/detail/os_file_functions.hpp:364:33: error: ‘SEEK_END’ cannot appear in a constant-expression /usr/local/include/boost/interprocess/detail/os_file_functions.hpp:365:33: error: ‘SEEK_CUR’ cannot appear in a constant-expression </pre><p> Only this order of includes causes the problem, changing the order makes compilation complete successfully and the program (along with a more complicated one) runs fine. </p> <p> The error happens on my Ubuntu 11.04 (natty), kernel: 2.6.38-8-generic, gcc (<a class="missing wiki">Ubuntu/Linaro</a> 4.5.2-8ubuntu4) 4.5.2 . It doesn't happen on my other machine with the same version of boost and any ordering of the includes, it runs Ubuntu 10.04.2 LTS (lucid), kernel: 2.6.32-30-generic, with gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 . </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5725 Trac 1.4.3 Ion Gaztañaga Sat, 24 Dec 2011 10:58:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5725#comment:1 https://svn.boost.org/trac10/ticket/5725#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">wontfix</span> </li> </ul> <p> I don't think it's an interprocess error. SEEK_SET is defined in &lt;unistd.h&gt; and Interprocess correctly includes it in os_file_functions.hpp. I don't know what do asio and mpi define to provoke the compilation error. </p> Ticket arandjelovic.relja@… Sat, 24 Dec 2011 15:05:13 GMT <link>https://svn.boost.org/trac10/ticket/5725#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5725#comment:2</guid> <description> <p> Hi, </p> <p> This is the first time I submit a bug report so I'm not sure what should I do next. Should I switch the component to asio or mpi and reopen the ticket? </p> <p> Thanks </p> <p> Relja </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Sat, 24 Dec 2011 16:59:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5725#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5725#comment:3</guid> <description> <p> Reija -- I think you should spend a bit more time investigating. </p> <ul><li>What does including ASIO bring to the table - why does it fail when you include ASIO (and not when you don't)? </li><li>Also, what version of Boost are you using? </li></ul><p> The code the compiler is whining about is: </p> <pre class="wiki">typedef enum { file_begin = SEEK_SET , file_end = SEEK_END , file_current = SEEK_CUR } file_pos_t; </pre><p> which (given sane values for SEEK_SET, etc) looks fine to me. What's the definition of SEEK_SET, etc on your machine? </p> <p> Here's the one from my (Mac): </p> <pre class="wiki">$ grep SEEK_SET /usr/include/stdio.h #ifndef SEEK_SET #define SEEK_SET 0 /* set file offset to offset */ </pre><p> I'm also wondering about this define in mph/config.h: </p> <pre class="wiki">/* Force MPICH not to define SEEK_SET, SEEK_CUR, and SEEK_END, which conflict with the versions in &lt;stdio.h&gt; and &lt;cstdio&gt;. */ #define MPICH_IGNORE_CXX_SEEK 1 </pre> </description> <category>Ticket</category> </item> </channel> </rss>