Modify

Ticket #6147 (closed Bugs: worksforme)

Opened 2 years ago

Last modified 6 months ago

message_queue sample fails to compile in 32-bit

Reported by: Graham Perks <graham@…> Owned by: igaztanaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.50.0 Severity: Regression
Keywords: Cc:

Description

Just upgraded to 1.48.

On OS X I compile the sample program with: gcc -I <blah path to boost>/include -arch i386 main.cpp

and it fails with "....boost/interprocess/ipc/message_queue.hpp:330: error: no matching function for call to ‘get_rounded_size(long unsigned int, const unsigned int&)’"

It's the MQ creation line that fails. If I build for x64, it compiles successfully. The source is:

#define BOOST_DATE_TIME_NO_LIB #include <boost/interprocess/ipc/message_queue.hpp> #include <iostream> #include <vector>

using namespace boost::interprocess;

int main () {

try{

Erase previous message queue message_queue::remove("message_queue");

Create a message_queue. message_queue mq (create_only only create

,"message_queue" name ,100 max message number ,sizeof(int) max message size );

Send 100 numbers for(int i = 0; i < 100; ++i){

mq.send(&i, sizeof(i), 0);

}

} catch(interprocess_exception &ex){

std::cout << ex.what() << std::endl; return 1;

}

return 0;

}

Attachments

Change History

comment:1 Changed 2 years ago by Graham Perks <graham@…>

Retry code formatting. It's the sample from the boost docs.

#define BOOST_DATE_TIME_NO_LIB
#include <boost/interprocess/ipc/message_queue.hpp>
#include <iostream>
#include <vector>

using namespace boost::interprocess;

int main ()
{
    try{
        //Erase previous message queue
        message_queue::remove("message_queue");
        
        //Create a message_queue.
        message_queue mq
        (create_only               //only create
         ,"message_queue"           //name
         ,100                       //max message number
         ,sizeof(int)               //max message size
         );
        
        //Send 100 numbers
        for(int i = 0; i < 100; ++i){
            mq.send(&i, sizeof(i), 0);
        }
    }
    catch(interprocess_exception &ex){
        std::cout << ex.what() << std::endl;
        return 1;
    }
    
    return 0;
}

comment:2 Changed 2 years ago by Graham Perks <graham@…>

If anyone has a workaround for this, it would be much appreciated.

comment:3 Changed 2 years ago by Graham Perks <graham@…>

I was able to workaround this by adding this code before including the boost headers. It adds a second type to the get_rounded_size template.

namespace boost {
    namespace interprocess { 
        namespace ipcdetail {
            
            //Rounds "orig_size" by excess to round_to bytes
            template<class SizeType, class ST2>
            inline SizeType get_rounded_size(SizeType orig_size, ST2 round_to)
            {
                return ((orig_size-1)/round_to+1)*round_to;
            }
        }
    }
}

comment:4 Changed 2 years ago by igaztanaga

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in trunk and release branches adding

#include <boost/interprocess/detail/utilities.hpp>

to message queue header.

comment:5 Changed 20 months ago by moala@…

  • Status changed from closed to reopened
  • Version changed from Boost 1.48.0 to Boost 1.50.0
  • Resolution fixed deleted

Still not fixed in i386 GCC 4.2 xcode 3.2.6 (only works in x86_64) even with this

#include <boost/interprocess/detail/utilities.hpp>

inclusion in message_queue.hpp in boost 1.50 (macports) (with Mac OS X 10.6 SDK / deployment target 10.5).

Graham Perks's workaround allows compiling.

comment:6 Changed 14 months ago by igaztanaga

I successfully compiled your test using trunk code in Mac OS 10.6.2 with GCC:

i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

can you check the bug is fixed?

comment:7 Changed 6 months ago by igaztanaga

  • Status changed from reopened to closed
  • Resolution set to worksforme

No news from the reporter so I'm closing the issue.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.