Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5725 closed Bugs (wontfix)

Different ordering of includes can lead to compilation errors ( ‘SEEK_SET’ cannot appear in a constant-expression etc )

Reported by: Relja Arandjelovic <arandjelovic.relja@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.46.1 Severity: Problem
Keywords: SEEK_SET, include ordering, compilation error, interprocess, mpi, asio Cc:

Description

Hi,

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:

#include <boost/asio.hpp>
#include <boost/mpi.hpp>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
int main(){ return 0; }

I get these errors:

/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

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.

The error happens on my Ubuntu 11.04 (natty), kernel: 2.6.38-8-generic, gcc (Ubuntu/Linaro 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 .

Change History (3)

comment:1 by Ion Gaztañaga, 11 years ago

Resolution: wontfix
Status: newclosed

I don't think it's an interprocess error. SEEK_SET is defined in <unistd.h> 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.

comment:2 by arandjelovic.relja@…, 11 years ago

Hi,

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?

Thanks

Relja

comment:3 by Marshall Clow, 11 years ago

Reija -- I think you should spend a bit more time investigating.

  • What does including ASIO bring to the table - why does it fail when you include ASIO (and not when you don't)?
  • Also, what version of Boost are you using?

The code the compiler is whining about is:

typedef enum { file_begin     = SEEK_SET
             , file_end       = SEEK_END
             , file_current   = SEEK_CUR
             } file_pos_t;

which (given sane values for SEEK_SET, etc) looks fine to me. What's the definition of SEEK_SET, etc on your machine?

Here's the one from my (Mac):

$ grep SEEK_SET /usr/include/stdio.h
#ifndef SEEK_SET
#define	SEEK_SET	0	/* set file offset to offset */

I'm also wondering about this define in mph/config.h:

/* Force MPICH not to define SEEK_SET, SEEK_CUR, and SEEK_END, which
   conflict with the versions in <stdio.h> and <cstdio>. */
#define MPICH_IGNORE_CXX_SEEK 1
Note: See TracTickets for help on using tickets.